Laravel theorytheory 0/50 · 0%
Eloquent · easy

11. Eloquent Relationships

Defining relations between models.

Eloquent supports hasOne, hasMany, belongsTo, belongsToMany, and hasManyThrough relationships defined as methods on the model. These return relationship objects that are lazily queried when accessed as properties, e.g. $user->posts. Pivot tables back many-to-many relationships and can carry extra columns.

Check your understanding

  1. 1. Which relationship method is used for a many-to-many relation?

  2. 2. On which model does belongsTo typically live?