I have my own Laravel gates defined "isAdmin" and "isManager". The "auth" middleware simply means the user is logged in. My routes look like this (greatly simplified):
Route::middleware(['auth', 'can:isAdmin'])->group(
function () {
Route::get('/', function() { return response("Admin home"); });
}
);
Route::middleware(['auth', 'can:isManager'])->group(
function () {
Route::get('/', function() { return response("Manager home"); });
}
);
But what do I do for a route for a logged-in user who is neither an admin nor a manager? I would like to do this:
Route::middleware(['auth', 'cannot:isManager', 'cannot:isAdmin'])->group(
function () {
Route::get('/', function() { return response("Who are you, anyway?"); });
}
);
Anybody have any ideas? Thanks.
you can set new rule (gate) as notAdminAndManager in app/Providers/AuthServiceProvider.php on boot method here is some example