-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Open
Labels
Description
Laravel Version
11.44.2
PHP Version
8.3
Database Driver & Version
No response
Description
Attaching Authorization
middleware does not work for route groups using can()
method, only via middleware('can...')
.
This does not work:
Route::prefix('{post}')
->can('access', 'post') // Middleware not registered.
->group(static function (): void {
Route::get('/', 'show')
...
});
Working example:
Route::prefix('{post}')
->middleware('can:access,post') // Middleware registered fine.
->group(static function (): void {
Route::get('/', 'show')
...
});
Steps To Reproduce
Route::prefix('{post}')
->can('access', 'post') // Middleware not registered.
->group(static function (): void {
Route::get('/', 'show')
...
});