How can I display subtotal and total to the view?
Here are the code
OrderProduct.php
protected $fillable = ['Subtotal','total'];
public function product()
{
return $this->belongsTo('App\Product');
}
Order.php
public function orderItems()
{
return $this->hasMany('App\OrderProduct');
}
Controller
$orders = Order::whereHas('orderItems.product', function ($query)
{
$query->where('user_id', '=', $User->id);
})->get();
Blade
@foreach ($order->orderItems as $item)
@if($item->product->user_id == $userID)
<td></td> <- display product name
<td></td> <- display product price
<td></td> <- display nothing
<td></td> <- display nothing
Any help would be appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire