public function postEditAlbum(EditAlbumRequest $request)
 {
     $album = Album::find($request->get('id'));
     $album->title = $request->get('title');
     $album->description = $request->get('description');
     $album->save();
     return redirect('validated/albums')->with(['edited' => 'The album has been edited']);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $id = $request->segment(4);
     $album = Album::find($id);
     if ($album == null) {
         return redirect('/validated/albums');
     }
     return $next($request);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = User::all();
     foreach ($users as $user) {
         $number = mt_rand(0, 15);
         for ($i = 0; $i < $number; $i++) {
             Album::create(['title' => "Title album {$i} of {$user->id}", 'description' => "Description album {$i} of {$user->id}", 'user_id' => $user->id]);
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Model::unguard();
     User::truncate();
     Album::truncate();
     // $this->call(UserTableSeeder::class);
     $this->call('UserTableSeeder');
     $this->call('AlbumTableSeeder');
     Model::reguard();
 }
 public function getIndex(ShowPhotosRequest $request)
 {
     $photos = Album::find($request->get('id'))->photos;
     return view('photos.show', ['photos' => $photos, 'id' => $request->get('id')]);
 }