我有两个主表,它们之间是多对多的关系,并且有一个中间表。
模型 产品
public function orders()
{
return $this->belongsToMany('App\Order');
}
模型顺序
public function products()
{
return $this->belongsToMany('App\Product', 'OrderDetails');
}
并且
$orders = Equipment::all();
@foreach($orders as $order)
@foreach($order->products as $product)
{!! $product->name !!} //it works
// How to print the value of the quantity?
@endforeach
@endforeach
我应该怎么做才能打印出数量的值呢?