dimanche 5 août 2018

Laravel - How to OR among middlewares for a route?

There is a table users in my website and a user is allowed to update a user if it is admin or it is his/her account. I can put this rule inside a middleware and impose it on the route but I want to create separate middlewares and OR among them. Can I do that?

The following code

Route::group(['middleware' => ['admin','Owner']],
    function () {
        Route::resource('roles', 'RoleController');
        Route::resource('locations', 'LocationController');
        Route::resource('recipients', 'RecipientController');
        Route::resource('classifications', 'ClassificationController');
    });

has AND behavior. I think it is possible to do this using some if ... else ... statement inside the web.php or the UserController but I need to know if there is any other way out.

Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire