I have three models that are linked through a pivot table. Per order I would like to know which part(s) have been used on which machine(s). For example, an order > belongsToMany() > parts.
order
- id
- date
machine
- id
part
- id
- name
order_machine_part (intermediate/pivot table)
- order_id
- machine_id
- part_id
Four classes:
When getting all parts for one order (Order::with('parts')->get()) I see the 'parts' relation on the Order model. This collection has different Part objects. The Part objects have a 'pivot' relation. The problem: how can I (eager) load the 'machine' relation for my pivot (OrderMachinePart)?
via Jeffrey