vendredi 20 décembre 2019

Eloquent resolve distant relationship

let's say I've this kind of structure.

| lines      |   | products |   | orders |
|------------|   |----------|   |--------|
| id         |   | id       |   | id     |
| product_id |   |----------|   |--------|
| order_id   |
|------------|

Is there a way in Laravel Eloquent to load related products given an order? I've tried with hasManyThrough(Product::class, Line::class) with no luck, because on products table there's no reference to the order. Is there a method that can resolve this relationship or should I write a raw query?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire