Javascript 连接单个数据单元中存在的多个json对象
我有一个列sayplaceditems,每次用户下订单时,都会存储一个json对象。因此,我能够成功显示第一个json对象(第一个订单)。它为第二个和第四个对象的foreach()提供了一个as无效参数`Javascript 连接单个数据单元中存在的多个json对象,javascript,php,arrays,json,laravel-5.2,Javascript,Php,Arrays,Json,Laravel 5.2,我有一个列sayplaceditems,每次用户下订单时,都会存储一个json对象。因此,我能够成功显示第一个json对象(第一个订单)。它为第二个和第四个对象的foreach()提供了一个as无效参数` Collection {#207 ▼ #items: array:1 [▼ 0 => Order {#211 ▼ #casts: array:1 [▶] #fillable: array:8 [▶] #connection: null #table: null
Collection {#207 ▼
#items: array:1 [▼
0 => Order {#211 ▼
#casts: array:1 [▶]
#fillable: array:8 [▶]
#connection: null
#table: null
#primaryKey: "id"
#keyType: "int"
#perPage: 15
+incrementing: true
+timestamps: true
#attributes: array:10 [▶]
#original: array:10 [▼
"id" => 1
"tableno" => "9"
"noofitems" => 2
"placeditems" => ""[{\"item\":\" Cafe Latte\",\"qty\":\"2\"}][{\"item\":\" Egg Sandwich\",\"qty\":\"3\"}]""
"total" => 106
"paidstatus" => 0
"deliveredstatus" => 0
"created_at" => "2017-07-14 11:32:29"
"updated_at" => "2017-07-14 11:36:37"
"username" => "harish"
]
#relations: []
#hidden: []
#visible: []
#appends: []
#guarded: array:1 [▶]
#dates: []
#dateFormat: null
#touches: []
#observables: []
#with: []
#morphClass: null
+exists: true
+wasRecentlyCreated: false
}
]
}
`
左视图叶片
@foreach($orders as $order)
@foreach(json_decode($order->placeditems, true) as $item)
<p>
{{ $item['item'] }}
<span>
( {{ $item['qty'] }} )
</span>
</p>
@endforeach
@endforeach
@foreach($orders作为$order)
@foreach(json_解码($order->placeditems,true)为$item)
{{$item['item']}
({{$item['qty']}})
@endforeach
@endforeach
如何更新第二个订单的字段?显示相关代码和数据结构。没有人会猜测为什么你的代码在看不到的时候会抛出错误。花些时间阅读和阅读