Skip to content
Advertisement

Laravel $requst->all() method returns an empty array

JavaScript

JavaScript

Route:

JavaScript

Controller:

JavaScript

Result:

JavaScript

I am wondering why $request->all() returns an empty array while var_dump($id) returns a value?

Advertisement

Answer

id is coming as a URL not as a query params or request body. Your route is reading it in the URL. If you pass it as a ?id=81 you will get it.

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