I have two main tables with many relationships and a pivot table.
Tables
Product model
public function orders()
{
return $this->belongsToMany('App\Order');
}
Model order
public function products()
{
return $this->belongsToMany('App\Product', 'OrderDetails');
}
and
$orders = Equipment::all();
@foreach($orders as $order)
@foreach($order->products as $product)
{!! $product->name !!}
@endforeach
@endforeach
What should I do to print the quantity value?
source
share