Check if the user has the given role to access the route.
Route::get('users/index', function() {
// ...
})->middleware('role:administrator');
For multiple roles, use |
as the delimiter.
Route::get('users/index', function() {
// ...
})->middleware('role:administrator|cashier');
Check if the user has the given permission to access the route.
Route::get('users/index', function() {
// ...
})->middleware('permission:users.view');
Check if the user has at least one of the given permission(s) to access the route.
{tip} Use comma separated list for multiple permissions.
Checking multiple permissions on a given route:
Route::get('users/index', function() {
// ...
})->middleware('canAtLeast:users.view,users.create');