diff --git a/middleware.md b/middleware.md index 13e6cff8a3..34b2e50e2b 100644 --- a/middleware.md +++ b/middleware.md @@ -131,6 +131,28 @@ You may assign multiple middleware to the route by passing an array of middlewar // ... })->middleware([First::class, Second::class]); +Also, you can use `using` method for set guards, set relative or absolute URL, set redirect and set rate limiter name for middleware: + +```php +Route::get('/', function () { + // ... +})->middleware([ + First::using('web'), // specify a guard + First::using('web', 'another'), // specify multiple guards + + Second::using('web', 'field'), // specify field + + Third::redirectTo('route.name'), // specify a redirect. + + Forth::relative(), // relative URL. + Forth::absolute(), // absolute URL. This is the default, but provided a named method for completeness. + + Fifth::using('gold-tier'), // named rate limiter + Fifth::with(100, 1, 'foo'), // custom with attempts, decay, and prefix + Fifth::with(prefix: 'foo'), // supports named arguments. +]); +``` + For convenience, you may assign aliases to middleware in your application's `app/Http/Kernel.php` file. By default, the `$middlewareAliases` property of this class contains entries for the middleware included with Laravel. You may add your own middleware to this list and assign it an alias of your choosing: // Within App\Http\Kernel class...