我有以下结构:
Order
id
Order_Products
id
order_id
product_id
Products
id
我正在尝试使用 hasManyTrough (https://laravel.com/docs/5.8/eloquent-relationships#has-many-through)。
我有类似的东西
class Order extends Model{
...
public function products()
{
return $this->hasManyThrough('App\Product', 'App\OrderProduct', 'product_id', 'id', 'order_id', 'id');
}
...
}
我不能让它工作。我很困惑,有人可以帮助我。