Reputation: 156
I'm writing rest apis in Laravel. Everything is ok when the request parameters are not nested. I can get any input parameters by ->
. e.g.
$model->update([
'column' => $request->value,
]);
However if I'd like the parameters to have nested structure, what is the way to get them? $request->value->nested_value
doesn't work as the value
is not an object.
Example of nested request parameters:
{
"parameters": {
"name": "game9",
"images": {
"icon_id": 1,
"banner_id": 1,
}
}
}
Upvotes: 0
Views: 230
Reputation: 348
When you get the values from the request, they are not objects
. They are arrays
.
You need to access them like this:
$request->value['nested_value']
Upvotes: 1