Skip to content

Commit 41beb9f

Browse files
committed
doc: global middleware usage
1 parent 116025e commit 41beb9f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ To protect specific routes, apply the middleware to them:
5656
use MasterRO\AccessScreen\Middleware\RedirectToAccessScreen;
5757

5858
Route::middleware([RedirectToAccessScreen::class])->group(function () {
59-
Route::get('/dashboard', function () {
60-
return view('dashboard');
61-
});
59+
Route::get('/dashboard', [DashboardController::class, 'index']);
6260
});
6361
```
6462

@@ -67,9 +65,10 @@ Route::middleware([RedirectToAccessScreen::class])->group(function () {
6765
To guard the entire application, apply the middleware globally in `bootstrap/app.php`:
6866

6967
```php
70-
$app->middleware([
71-
\MasterRO\AccessScreen\Middleware\RedirectToAccessScreen::class,
72-
]);
68+
$app
69+
->withMiddleware(function (Middleware $middleware) {
70+
$middleware->use([RedirectToAccessScreen::class]);
71+
})
7372
```
7473

7574
## Generating an Access Key

0 commit comments

Comments
 (0)