Reputation: 496
When I return the request of my controller, I get:
{"employees":"3","reason":"common reason","request":"5000","ded_per_pay":"500","months_to_pay":"2","date_issued":"2018-01-31"}
And in my create function, I get this error:
Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string
Here's my code:
CashAdvance::create([
'emp_id' => $request->employees,
'reason' => $request->reason,
'request' => $request->request,
'ded_per_pay' => $request->ded_per_pay,
'date_issued' => $request->date_issued,
'months_to_pay' => $request->months_to_pay
]);
What seems to be causing the problem??
Upvotes: 0
Views: 1413
Reputation: 1871
This is really interesting. I've had a look in the API docs and it appears that the Request object has a parameter request
. Which means that when you are calling $request->request
, you are getting the parameter bag from your $request
.
To get around this, you can use something like:
$myRequest = $request->input('request');
But I would heavily advise that instead you rename request
to something that won't confuse yourself/other devs later in the project, and to keep these special named variables reserved for what they actually mean.
Upvotes: 1