【发布时间】:2020-10-01 18:46:42
【问题描述】:
我在我的项目中使用 laravel,所以当我在购物车中添加产品时,所有数据都会显示,除了产品图片。
这是购物车控制器.php:
public function add(Request $request) {
$produit=productmodel::find($request->id);
Cart::add(array(
'id' =>$request->id, // inique row ID
'name' =>$request->product_name,
'price' => $request->product_price,
'quantity' =>$request->product_quantity,
'attributes' => array('photo'=>$request->product_image)));
return redirect ('shop-cart');
}
这是 shop-cart.blade.php
<tbody>
@foreach(\Cart::getContent() as $item)
<tr>
<td class="cart__product__item">
<div class="cart__product__item__title">
<img src="{{asset('storage/product/September2020/'.$item->attributes['photo'])}}" alt="">
<h6> {{Str::words($item->name,20) }}</h6>
@foreach($item->attributes as $key => $value)
<dl class="dlist-inline small">
<dt>{{ ucwords($key) }}: </dt>
<dd>{{ ucwords($value) }}</dd>
</dl>
@endforeach
</div>
</td>
<td class="cart__price"> {{$item->price}} TND</td>
<td class="cart__quantity">
{{ $item->quantity }}
</td>
<td class="cart__total"> {{ $item->price * $item->quantity }} TND</td>
<td class="cart__close"><a href="{{ route('checkout.cart.remove', $item->id) }}"><i class="fa fa-times"></i> </a>
</td>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
【问题讨论】:
-
stackoverflow.com/questions/64099558/… 这不是同一个问题吗?你之前的问题
标签: laravel e-commerce cart