Laravel 5 Resourceful Routes Plus Middleware

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']]);
});

In QuotesController constructor you can then use:

$this->middleware('auth', ['except' => ['index','show']]);

Reference: Controller middleware in Laravel 5


UPDATE FOR LARAVEL 8.x

web.php:

Route::resource('quotes', 'QuotesController');

in your controller:

public function __construct()
{
        $this->middleware('auth')->except(['index','show']);
        // OR
        $this->middleware('auth')->only(['store','update','edit','create']);
}

Reference: Controller Middleware


In Laravel with PHP 7, it didn't work for me with multi-method exclude until wrote

Route::group(['middleware' => 'auth:api'], function() {
        
Route::resource('categories', 'CategoryController', ['except' => 'show,index']);
});

maybe that helps someone.