In this it is written that the parameters can be separated by commas.
https://laravel.com/docs/5.3/middleware#middleware-parameters
I am creating a new project in Laravel 5.3 .
Since 2 hours i am thinking about the problem that why my middleware with the parameters is not working.
And everywhere it is suggested that it should be separated by comma (,) . But none of the suggestion was helpful.
Now when i tried passing the parameters using a semicolon ( ; ) then my middleware was working properly.
Route::get('/sid/sam', function () {
return 'Hello World from sam1';
})->middleware('role:Admin;Superadmin');
Thanks . May be this suggestion is helpful.
:-)
@sammysri commas are intented to pass multiple parameters, not multiple values.
imagine the following scenario:
->middleware('role:Admin,staff:false')
that's how commas are supposed to work, if you need multiple values on role, you can use any separation you like, as admin|operation|guest as long you break then down on your middleware
If you define the handle method like this:
public function handle($request, Closure $next, ...$args)
And you pass role:admin,superadmin to the kernel.
the output of $args in the middleware will be an array ['admin', 'superadmin'].
Most helpful comment
If you define the handle method like this:
And you pass
role:admin,superadminto the kernel.the output of
$argsin the middleware will be an array['admin', 'superadmin'].