vendredi 29 mars 2019

hasManyThrough relationship in Laravel 5.8

I have the following struct:

Order
 id

Order_Products
 id
 order_id
 product_id

Products
 id

Im trying to use hasManyTrough (https://laravel.com/docs/5.8/eloquent-relationships#has-many-through).

I have something like

class Order extends Model{
...
public function products()
{
    return $this->hasManyThrough('App\Product', 'App\OrderProduct', 'product_id', 'id', 'order_id', 'id');
}
...
}

I can not make it work. I'm confused, can someone help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire