public function getPhotos() {
$photos = \DB::table('photo')
->join('share', 'photo.id', '=', 'share.photo_id')
->get()
->groupBy('photo_id')
->map(function ($photo) {
return [
'id' => $photo[0]->photo_id,
'title' => $photo[0]->title,
'url' => 'http://photoservice.ru/' . $photo[0]->path,
'owner_id' => $photo[0]->owner_id,
'users' => $photo->pluck('user_id')
];
})->values();
return response()->json($photos, 200);
}