Skip to content

Commit 96d800a

Browse files
authored
Add example for HasMiddleware interface in Laravel 11
Closes #2647
1 parent 44bbe88 commit 96d800a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/basic-usage/middleware.md

+12
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ Route::group(['middleware' => ['permission:publish articles|edit articles,api']]
8585

8686
### Controllers
8787

88+
In Laravel 11, if your controller implements the `HasMiddleware` interface, you can register controller middleware using the `middleware()` method:
89+
90+
```php
91+
public static function middleware(): array
92+
{
93+
return [
94+
'role_or_permission:manager|edit articles',
95+
];
96+
}
97+
```
98+
99+
Or, like in prior versions, you can register it in the constructor:
88100
```php
89101
public function __construct()
90102
{

0 commit comments

Comments
 (0)