Eloquent Relationships

A foreign key in MySQL was a column plus a JOIN you wrote each time. In Eloquent it becomes a method returning a relationship object: read as a property ($order->customer) it runs once and is cached on the model; called ($customer->orders()) it is a builder you can filter, count and write through. The models are Eloquent Models's plus Category, Review, Address, Image and Tag; output starting with -- lines ran with the Eloquent Models query listener, and long SQL is wrapped. Each arrow below starts at the model that declares the method. Query counts are Eager Loading.

The shop's models and the relationships this section defines between them
The shop's models and the relationships this section defines between them

Subsections