Skip to content
Advertisement

Laravel: how to pass GET array to controller?

How to pass array of GET parameters to the controller?

This is my route file routes/web.php:

JavaScript

And my controller ‘app/Http/Controllers/Parser.php’:

JavaScript

So, I expect to get an array of parameters like this:

JavaScript

But if I pass GET array to my route path: http://example.com/ids?ids[]=1&ids[]=2&ids[]=15&ids[]=25

I get an empty request object anyway:

{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}

Advertisement

Answer

There is few ways to get data from GET. Try something like that:

JavaScript

or:

JavaScript

More info you can get in documentation

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