Reputation: 8378
I have an Axios post request which sends a phone number to my Laravel backend. It was working fine until I deleted a column in my database. It still returns a 201 but the value isn't updated. When I dd()
the request, it's now a protected property instead of how it was before:
#json: Symfony\Component\HttpFoundation\ParameterBag {#35
#parameters: array:1 [
"field" => array:2 [
"phone_number" => "079600565197"
"id" => 35
]
]
}
So whereas before I could do:
$account->phone_number = $request->get('phone_number');
$account->save();
All it saves is null
.
When I check the request in devtools it looks fine:
field: {phone_number: "07960065197", id: 35}
But I can't access the data inside field
.
Is there a way I can either convert this back to how it was before, or access the nested data directly? Any tips would be a great help.
Upvotes: 0
Views: 242
Reputation: 997
You are nesting your 'phone_number'
attribute inside the 'field'
attribute.
To retrieve nested attributes from your request do this:
$request->input('field.phone_number')
Upvotes: 1