Laravel 5 Resourceful Routes Plus Middleware

后端 未结 4 873
一生所求
一生所求 2020-12-13 05:38

Is it possible to add middleware to all or some items of a resourceful route?

For example...



        
4条回答
  •  旧巷少年郎
    2020-12-13 06:19

    In laravel 5.5 with php 7 it didn't worked for me with multi-method exclude until I wrote

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

    maybe that help someone.

提交回复
热议问题