Skip to content
Advertisement

Laravel, only first element of array passed to route is readable

From a blade template I want to pass an array with a variable amount of values to a route, as described in the answer here.

However when I do this I can only ever access the first value in the array I pass to the route.

This is how I call the route in the blade template:

JavaScript

this is my route from web.php:

JavaScript

and my controller:

JavaScript

The problem is, that I can only ever access the first value of the array I pass to the controller (stat_kind in this case). It doesn’t natter in which order I call the get() function either.

What can I do to fix this?

I’m running laravel 5

Advertisement

Answer

Try changing the curly braces, {{ }}, to {!! !!} where you are calling the route helper.

The & is being encoded to & so only the first query string parameter that you are sending does not have a & in front of it so it is named correctly. The others are named with the amp;, the part after the & in the encoded ampersand.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement