我将JSON返回到我的前端,如下所示: p>
public function newFlavorOrders()
{
$ orders = request() - > user() - > ordersPaid;
return response() - > json(['flavor_orders'=> $ orders]);
}
code> pre>
现在,将其返回到前端: p>
{orders:[\ n {
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“}]
}
]
}
code> pre>
但我想要 更改控制器PHP函数以向每个 order_products code>项添加字段。 我有 imgURL code>,但我想添加 processedImgUrl code>并立即将其与 true code>存根。 如何在返回JSON时将字段添加到上面的php函数中? p>
div>