我的数据如下:
data: [,…]
0: {name: "Product One", price: "15000", quantity: 2, attributes: {attr: {name: "weight", value: "35"}},…}
attributes: {attr: {name: "weight", value: "35"}}
conditions: [{name: "blue", value: 0}, {name: "L", value: 0}]
name: "Product One"
price: "15000"
quantity: 2
我需要添加id到每个数据数组中,例如:
data: [,…]
0: {name: "Product One", price: "15000", quantity: 2, attributes: {attr: {name: "weight", value: "35"}},…}
attributes: {attr: {name: "weight", value: "35"}}
conditions: [{name: "blue", value: 0}, {name: "L", value: 0}]
name: "Product One"
price: "15000"
quantity: 2
id: 10 // added id
截屏
我的数据库如下所示:
代码
目前刚刚获得我的专栏,还cart_data需要添加专栏。id
$items2 = CartStorage::where('user_id', $user->id)->get();
$items = [];
foreach($items2 as $item){
$items[] = json_decode($item['cart_data']);
}
函数式编程