O'Reilly logo

Laravel Application Development Blueprints by Halil İbrahim Yılmaz, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving photos between albums

Moving photos between albums is a great feature for managing the album's images. Many photo gallery systems come with this feature. So, we can code it easily with Laravel. We need a form and controller function for adding this feature to our photo gallery system. Let's code the controller function first. Open the ImagesController.php file which is located in app/controllers/ and add the following code in it:

public function postMove() { $rules = array( 'new_album' => 'required|numeric|exists:albums,id', 'photo'=>'required|numeric|exists:images,id' ); $validator = Validator::make(Input::all(), $rules); if($validator->fails()){ return Redirect::route('index'); } $image = Image::find(Input::get('photo')); $image->album_id ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required