SamLim
SamLim

Reputation: 63

Why $request got nothing but $request->something is available?

Laravel - 5.7.* PHP - 7.1.3

Why does json_encode($request) give me this response:

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

But when I $request->id <<< (What I pass in), I'm able to get the ID.

Why won't it show the ID in the $request when I print it out?

Upvotes: 1

Views: 522

Answers (1)

Rouhollah Mazarei
Rouhollah Mazarei

Reputation: 4153

Use

$request->all()

to get whatever has been sent to controller.

You can read about this in Laravel documentation

Upvotes: 3

Related Questions