I recently started using Laravel 5 and I'm having a lot of trouble implementing a system that not only authorizes users, but also checks permissions.
In all of the examples I've dug up online, I see two items being applied as middleware. For example:
Route::group(['middleware' => ['auth', 'permissions']], function() {
// protected routes here
Route::get('admin', 'DashboardController@index');
});
However, I cannot get this to work no matter what I do. I can only apply one item as middleware, such as:
Route::group(['middleware' => 'auth'], function() {
// protected routes here
Route::get('admin', 'DashboardController@index');
});
If I apply two, I get the error "Route [admin] not defined."
I have tried everything I can think of, and I am banging my head against a brick wall. How on earth can I apply two or more items of middleware to one route?
You might juste try to create one middleware doing more than on verification ?
In your Kernel.php you might have something like :
protected $routeMiddleware = [
'auth' => 'Your\Route\Authenticate',
'auth.permissions' => 'Your\Route\AuthenticateWithPermissions'
'permissions' => 'Your\Route\RedirectIfNoPermissions'
]