O'Reilly logo

Getting Started with Laravel 4 by Raphaël Saunier

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

Back to the routes

Now that we have a main template that we can extend and re-use, we can start to create the individual routes of our application inside app/routes.php, along with the different views that will display the application data.

The overview page

This is the index page that is going to display all of the cats using the cats.index view. We will also re-use this view for the second route where the cats are filtered by their breed, since both the routes are almost identical. Note that Laravel expects you to use the dot notation (cats.index and not cats/index) to refer to a view located inside a subfolder:

Route::get('cats', function(){ $cats = Cat::all(); return View::make('cats.index') ->with('cats', $cats); }); Route::get('cats/breeds/{name}', ...

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