Is it possible to add middleware to all or some items of a resourceful route?
For example...
<?php Route::resource('quotes', 'QuotesController');
Furthermore, if possible, I wanted to make all routes aside from index
and show
use the auth
middleware. Or would this be something that needs to be done within the controller?
In QuotesController
constructor you can then use:
$this->middleware('auth', ['except' => ['index','show']]);
Reference: Controller middleware in Laravel 5
You could use Route Group coupled with Middleware concept: http://laravel.com/docs/master/routing
Route::group(['middleware' => 'auth'], function() { Route::resource('todo', 'TodoController', ['only' => ['index']]); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With