Skip to content
Nav

Route middleware

composer require langsys/laravel-access-guard
Packagist version Monthly downloads License PHP 8.2+ Laravel 10 / 11 / 12
Route::get('/projects/{project}', [ProjectController::class, 'show'])
->middleware('access-guard:view_projects,project');

The first argument is the permission; the optional second names the route parameter holding the entity (otherwise the first route-bound GuardableResource is used). Denial throws UnauthorizedException (403) — see Exceptions.

Feedback