@vpower Its a documentation issue. The examples are very unclear as to how its works. I took a quick look at the code. But I dont use it so. But the key before the colon should be the same one you use to register the middleware. The values after that are what get passed? Entry corresponds to a variable passed after the Closure field. You have to step through all the indirection of how the Middleware gets loaded to see how those extra parameters get accessed.
Middleware Multiparams (bug?)
Hi,
I might have discovered a bug in laravel. I want to verify that's the and make sure i'm not making any errors:
Route::get('/', ['uses' =>'HomeController@index', 'middleware' => ['permission:office,other', 'role:admin']]);
The middleware for permission should receive a array with "office" and "other" as laravel.com quotes:
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.
In my case it doesn't return a array. It returns only the first param "office".
Can anyone verify this is a bug and not a coding error so i can report this?
Thanks.
V
Hi @jimmck
Thanks for your response.
I have found several cases where they use this examples. See further in my application. The middleware is applied correctly. In the array in Kernel.php the is permission. Everything is working correctly except the parameter passing.
@d3xt3r funny thing is it think it should. Take a look at: https://ahesanalisuthar.wordpress.com/2015/06/04/laravel-5-1-pass-middleware-parameters-as-array/
When i change the comma for a dash, the string is received correctly. Now only one out of two params are received. It might be a version difference where it's simply changed. But i want to make sure before i start implementing a different solution.
Why else do they point out to use the comma?
@jimmck i chose for the hard coded values to identify that part of the application in my middlewares. Depending on role or permissions. That way i can redirect them before entering the application in case they are not authorized.
Please or to participate in this conversation.