I am returning JSON to my frontend like this:
public function newFlavorOrders()
{
$orders = request()->user()->ordersPaid;
return response()->json(['flavor_orders' => $orders]);
}
and right now, that returns this to the frontend:
{ orders: [
{
color: "Green"
size: "Large",
order_products: [ {'itemNum': 3, 'imgUrl': "zera.jpg"}, {'itemNum': 5, 'imgUrl': "murto.jpg"} ]
},
{
color: "Blue"
size: "Large",
order_products: [ {'itemNum': 3, 'imgUrl': "mcue.jpg"}, {'itemNum': 5, 'imgUrl': "cloa.jpg"} ]
}
]
}
But I want to alter the controller PHP function to add a field to each order_products
item. I have the imgURL
, but I want to add a processedImgUrl
and stub it with true
right now. How can I add the field to the above php function when returning the JSON?