Try the filter inside Route to make sure its working or not...and post the result here
Sorry for the late answer, I was on holiday. This is my routes code for the controllers I would like to have an auth filter on. I want all routes except store to be auth-filtered. How would I do this in routes? I only managed to do this with auth filter in the constructor of my controller.
Route::group(array('prefix' => 'api'), function() {
Route::resource('customers', 'CustomersController',
array('only' => array('index', 'show', 'store', 'destroy', 'update')));
Route::resource('tickets', 'TicketsController',
array('only' => array('index', 'show', 'store', 'destroy', 'update')));
Route::resource('questions', 'QuestionsController',
array('only' => array('index', 'show', 'store', 'destroy', 'update')));
});
Also, I tried the constructor auth filter on another remote server (Fortrabbit) and it still doesn't work..
Where are you defining your Auth filter? Is this being included by your application at run time?
I included the filter in the constructor, as you can see in the first code example. Then codetrash suggested to put it in to my Route, but I can't seem to get it to work there. So that was the second part of my question, how to include it in my Route.
I'm just a Laravel beginner, so sorry for any stupid questions..
This is covered in a couple of places in the docs:
http://laravel.com/docs/routing#route-groups
http://laravel.com/docs/routing#route-filters
http://laravel.com/docs/controllers#controller-filters
You most likely would add your filter to the route group, using the 'before' option:
Route::group(array('prefix' => 'api', 'before' => 'auth'), function() {
Yes, I got that working, but I want the auth filter on all my resource methods except the store. I can't seem to do this:
('auth', array('except' => 'store'));
I'm having the same issue. Anyone figure it out yet?
Edit: Found it! For anyone coming from Google, see here: http://laravel.io/forum/02-15-2014-no-filter-working-on-testing-server-but-working-on-local-develpment?page=1
Edit 2: Created pull request for the docs: https://github.com/laravel/docs/pull/951
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community