【发布时间】:2019-07-17 22:05:03
【问题描述】:
我正在使用名为 Gloudemans\Shoppingcart 的购物车; (更多关于购物车:https://github.com/Crinsane/LaravelShoppingcart),在购物车内我存储了许多变量,其中一个是产品表中的 id,我使用购物车在 Blade 视图中显示存储在购物车中的项目,我想要而不是显示产品 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,
]
【问题讨论】:
-
请在您的购物车中发布内容和产品型号。