Skip to content

Commit

Permalink
Added more Laravel 11 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte committed Apr 4, 2024
1 parent d26563e commit 536d41d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/basic-usage/middleware.md
Expand Up @@ -91,8 +91,11 @@ In Laravel 11, if your controller implements the `HasMiddleware` interface, you
public static function middleware(): array
{
return [
// examples with aliases, pipe-separated names, guards, etc:
'role_or_permission:manager|edit articles',
new Middleware('role:author', only: ['index']),
new Middleware(\Spatie\Permission\Middleware\RoleMiddleware::using('manager'), except:['show']),
new Middleware(\Spatie\Permission\Middleware\PermissionMiddleware::using('delete records,api'), only:['destroy']),
];
}
```
Expand All @@ -101,8 +104,8 @@ In Laravel 10 and older, you can register it in the constructor:
```php
public function __construct()
{
// examples:
$this->middleware(['role:manager','permission:publish articles|edit articles']);
// or
$this->middleware(['role_or_permission:manager|edit articles']);
// or with specific guard
$this->middleware(['role_or_permission:manager|edit articles,api']);
Expand Down

0 comments on commit 536d41d

Please sign in to comment.