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

Creating an album

As you know from the previous chapters in this book, Laravel has a great RESTful controller mechanism. We'll continue to use that to keep the code simple and short during development. In the next chapters, we'll cover another great controller/routing method named Resource Controllers.

To list, create, and delete an album, we need some functions in our controller. To create them, save the following code as AlbumsController.php in the app/controllers/ directory:

<?php class AlbumsController extends BaseController{ public function getList() { $albums = Album::with('Photos')->get(); return View::make('index') ->with('albums',$albums); } public function getAlbum($id) { $album = Album::with('Photos')->find($id); return View::make('album') ...

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