I am trying to create custom authorization and authentication in Laravel 5.2.
So in my routes file, first i check if user is authenticated or not, usingauthmiddleware.
Route::group(['middleware' => ['auth']], function () {
});
I have 3 users role.
1.visitor
2.manager
3.admin
and for manager and admin i have two middleware.
ManagerMiddleware(manager) andAminMiddleware(admin)
For a specific function i want to give access to bothadminandmanager.
For this purpose , i used this code
Route::group(['middleware' => ['auth']], function () {
Route::group(['middleware' => ['admin','manager']], function () {
Route::get('test','TestController@index')
});
});
Of course it does not work. Second middleware check bothadminandmanagerand it fails because an user only belongs to a specific role.
So i want to useorin['middleware' => ['admin','manager']]
Is there any way to do it in Laravel?