I have set up a resource controller using jefferyway's laravel4 generator as player. So when i go to the url /players/show it shows me the show.blade.php. That's correct. But when I go to the /players/{whatever name field i can pass} it goes to the show.blade.php. No error thrown of httpnotfoundexception or anything.
These are the controller and routes file for the application.
That's the way it's supposed to work.
The show
method on line 45 handles GET requests to /players/{anything}
.
Jeffery Way has a really nice screencast series on Laravel 4, and he explains this in detail:
Resourceful Controllers: Part 1
Resourceful Controllers: Part 2
When you register a resource controller, it will create those routes for you :
GET /players players.index PlayerController@index
GET /players/create players.create PlayerController@create
POST /players players.store PlayerController@store
GET /players/{players} players.show PlayerController@show
GET /players/{players}/edit players.edit PlayerController@edit
PUT /players/{players} players.update PlayerController@update
PATCH /players/{players} PlayerController@update
DELETE /players/{players} players.destroy PlayerController@destroy
You can have this list with : php artisan routes
You can now see players.show will handle /players/*
Use Example:
Route::group(array('before' => 'auth'), function()
{
Route::get('/', function()
{
// Has Auth Filter
});
Route::get('user/profile', function()
{
// Has Auth Filter
});
});