3.4 Eloquent Relations
Relations may be Eloquent’s most powerful feature. With just a few lines of code you can create one-to-one, one-to-many, or even many-to-many relations. It’s as easy as defining
$this->belongsToMany('Category');. In this lesson, we’ll use all of them: Users to Phones (one-to-one), Users to Posts (one-to-many) and Posts to Categories (many-to-many, using a pivot table). Also, we’ll implement eager loading, which will dramatically speed up your application when using relations and cure the so-called n+1 problem.
Note: Eloquent relations live in