输出
array:2 [▼
0 => array:1 [▼
0 => array:12 [▼
"product_name" => "Raw Mango"
"product_image" => "Raw_Mango_1997.jpg"
"product_id" => "15"
"variation_id" => "33"
"original_price" => "15.31"
"selling_price" => "12.25"
"discount_price" => "3.06"
"discount_percent" => "20"
"product_stock" => "available"
"product_unit" => "gram"
"product_unit_value" => "250"
"cart_quantity" => "1"
]
]
1 => array:1 [▼
0 => array:12 [▼
"product_name" => "Banana - Yelakki"
"product_image" => "Banana_-_Yelakki_9339.jpg"
"product_id" => "20"
"variation_id" => "41"
"original_price" => "56.25"
"selling_price" => "45"
"discount_price" => "11.25"
"discount_percent" => "20"
"product_stock" => "available"
"product_unit" => "gram"
"product_unit_value" => "500"
"cart_quantity" => "1"
]
]
]
如何在laravel刀片页面中显示这种类型的数据。我想在对象中获取数据以在laravel视图页面中显示数据。我尝试了很多方法但没有得到解决方案请帮助我
购物车控制器.php
public function viewCart(){
$select=DB::table('carts')->where('user_id','=',Session::get('user_id'))->get();
$count=count($select);
if($count>0)
{
foreach($select as $row1)
{
$product_id = $row1->product_id;
$variation_id = $row1->variation_id;
$quantity = $row1->quantity;
$sql=DB::table('products')->where('id','=',$product_id)->get();
$arr=array();
foreach($sql as $res)
{
$product_name = $res->product_name;
$image = $res->product_image;
$product_desc = $res->product_desc;
$sql1=DB::table('product_details')->where('product_id','=',$product_id)->where('id','=',$variation_id)->get();
foreach($sql1 as $res1)
我试图在页面上获取用户添加的购物车详细信息,但是当尝试 foreach 时,它会出错。如何在 laravel 视图页面中迭代这种类型的数据,请帮助我。
千万里不及你