我使用名为 Gloudemans\Shoppingcart 的购物车;(有关购物车的更多信息:https : //github.com/Crinsane/LaravelShoppingcart),在购物车内我存储了许多变量,其中之一是产品表中的 id,我使用购物车在刀片视图中显示购物车中存储的项目,我不想显示产品 ID 来显示产品名称,但不能在购物车中使用 leftjoin,因为它说 Method leftjoin 不存在。
控制器:
$cartContents=Cart::Content();
$products= Product::all();
刀片视图:
@foreach($cartContents as $cartContent)
{{$cartContent->id}} // here I want to show product name not product id
@endforeach
产品型号:
protected $table="products";
protected $fillable=[
'category_id',
'storeinfo_id',
'product_price',
'product_name',
'product_details',
'product_unitsize',
'product_unitsizelast',
'product_unitname',
'product_unittext',
'product_unitserve',
'product_image',
'show'
];
大车:
Cart::add([
'id' => $request->cartproductid,
'name' =>$request->special,
'qty' => $request->cart_quantity,
'price' => $request->cart_price,
'name' =>$request->special,
'options' =>
[
'size' =>$request->cart_size,
'storeinfo_id' =>$request->storeinfo_id,
'serve' => $request->cart_serve,
]
慕斯王