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]); }
/** * Permet d'aficher la page d'ajout de photo * * @param int $id * @return View */ public function photosAddView($id) { $album = Albums::find($id); return view('albums.photos', compact('album')); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::table('Albums')->delete(); \App\Albums::create(['name' => 'All', "id" => 1]); }
/** * 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]); }