Laravel-permission: How to add multiple roles in Route::group ?

Created on 3 May 2017  路  3Comments  路  Source: spatie/laravel-permission

Im trying to add more that one role in the Route::group.

Route::group(['middleware' => ['role:[admin,editor]']], function () { Route::get('admin/general', 'AdminController@general'); });

Is this possible ?

Most helpful comment

In the readme file example, you are setting ['middleware' => ['role:admin,access_backend']], but access_backend is a passed as a permission when it comes to the middleware, not as a role param. So is that possible add more than one role ?

All 3 comments

There's an example on how to do this in the readme.

In the readme file example, you are setting ['middleware' => ['role:admin,access_backend']], but access_backend is a passed as a permission when it comes to the middleware, not as a role param. So is that possible add more than one role ?

Try Route::group(['middleware' => ['role:admin|editor']]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tripex picture tripex  路  3Comments

younus93 picture younus93  路  4Comments

dylangeorgeharbour picture dylangeorgeharbour  路  3Comments

NattananWs picture NattananWs  路  3Comments

MichalKrakow picture MichalKrakow  路  4Comments