'Passing multiple parameters to Laravel API

I need to filter my API using multiple parameters. So how i can put my array of parameters to API Controller?



Solution 1:[1]

If you add Request $request as a parameter in your controller functions, that will allow you to access any passed parameters through:

$request->input('parameter_1')

Sometimes you will need to protect your code in-case the parameter was not sent, in which case you can use:

isset($request->has('parameter_1'))

That will return false if this parameter was not sent with the request. Let me know if you meant something else.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gowl