Home > Mobile >  Laravel Middleware Parameters with fully qualified class name
Laravel Middleware Parameters with fully qualified class name

Time:04-11

"When assigning middleware, you may also pass the fully qualified class name:" https://laravel.com/docs/9.x/middleware#assigning-middleware-to-routes

"Middleware parameters may be specified when defining the route by separating the middleware name and parameters with a :. Multiple parameters should be delimited by commas:" https://laravel.com/docs/9.x/middleware#middleware-parameters

How to assign parameters with the fully qualified class names?

CodePudding user response:

You can simply concatenate class namespace to the parameters, something like below:

Route::get('/', function () {
    return view('welcome');
})
    ->middleware(\App\Http\Middleware\Dummy::class . ':value1,value2');
  • Related