Arrays 将数据库中保存的数组格式化为laravel中的刀片视图
我有一个DB表,它存储id、购物车(数组)、更新位置、创建位置。如何解构数组并将视图中的项显示为列表项 三, {“3”:{“名称”:“iPhone”,“数量”:2,“价格”:“500.00”},“4”: {“名称”:“三星”,“数量”:1,“价格”:“344.00”} 2019-11-10 07:50:53Arrays 将数据库中保存的数组格式化为laravel中的刀片视图,arrays,laravel,Arrays,Laravel,我有一个DB表,它存储id、购物车(数组)、更新位置、创建位置。如何解构数组并将视图中的项显示为列表项 三, {“3”:{“名称”:“iPhone”,“数量”:2,“价格”:“500.00”},“4”: {“名称”:“三星”,“数量”:1,“价格”:“344.00”} 2019-11-10 07:50:53 ______________________ ProductsController ______________________ public function cartsIndex(Req
______________________
ProductsController
______________________
public function cartsIndex(Request $request)
{
$carts = Cart::all();
$carts = json_decode($carts);
// return view('cartsIndex')->with(['carts' => $carts]);
dd($carts);
}
我希望购物车显示如下
- ID-3
- 名称:Iphone
- 数量:2
- 价格:500
- 名称:三星
- 数量:1
- 售价:344
- 名称:Iphone
protected $cast = [
'cart' => 'array' // name of the column you want to store as json and retrieve as array
];
作为参考是一个多维数组吗??看起来是这样的。它是一个多维数组