public function albums() { $albums = Albums::where('parent', '0')->get(); foreach ($albums as $parent) { foreach ($parent->childrens as $babies) { $picture = $babies->photos->random(1); $parent->randomPicture = $picture; } } return view('page/albums', ["albums" => $albums]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $albums = Albums::where('ID_proprietaire', '=', Auth::user()->id)->get(); return view('albums.index', compact('albums')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $album = Albums::where('slug', $id)->first(); return view('albums.show', ['album' => $album]); }