I'm trying to create a group Route for the admin section and apply the middleware to all paths except for login and logout.
What I have so far is:
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => 'authAdmin'], function() {
Route::resource('page', 'PageController');
Route::resource('article', 'ArticleController');
Route::resource('gallery', 'GalleryController');
Route::resource('user', 'UserController');
// ...
});
How would I declare exceptions for the middleware with the above setup?
Simply nest groups and then you can exclude specific routes:
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {
Route::get('login', 'AuthController@login');
Route::get('logout', 'AuthController@logout');
Route::group(['middleware' => 'authAdmin'], function(){
Route::resource('page', 'PageController');
Route::resource('article', 'ArticleController');
Route::resource('gallery', 'GalleryController');
Route::resource('user', 'UserController');
// ...
});
});