I need to put middleware on route in lumen project. So far I've been working with Laravel but now I'm in a project that is using lumen.
Documentation here: https://lumen.laravel.com/docs/5.4/middleware
gives us
$app->get('admin/profile', ['middleware' => 'auth', function () {
//
}]);
while my route look like this
$app->get('/', 'UsersController@all');
I've tried this:
$app->get('/', ['middleware' => 'haspermission:backend-users-list'], 'UsersController@all');
but it does not work.
What is the right way to do it if I am not using a function directly in route to return some data?
Try this solution github
$app->get('/', ['middleware' => 'haspermission:backend-users-list', 'uses' => 'UsersController@all']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With