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']); }
/** * 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'); $this->call('AlbumTableSeeder'); }
/** * 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(); //delete the previous db data and then seed the db Album::truncate(); $this->call('UserTableSeeder'); $this->call('AlbumTableSeeder'); }
/** * @param DeleteAlbumRequest $request * @return string */ public function postDeleteAlbum(DeleteAlbumRequest $request) { $album = Album::find($request->get('id')); $photos = $album->photos; $controller = new PhotoController(); foreach ($photos as $photo) { $controller->deleteImage($photo->path); $photo->delete(); } $album->delete(); return redirect('validated/albums')->with(['deleted' => 'The album was deleted']); }
public function getIndex(ShowPhotosRequest $request) { $photos = Album::find($request->get('id'))->photos; return view('photos.show', ['photos' => $photos, 'id' => $request->get('id')]); }