When accessing Eloquent relationships as properties, the relationship data is "lazy loaded".
This means the relationship data is not actually loaded until you first access the property.
However, Eloquent can "eager load" relationships at the time you query the parent model.
Eager loading alleviates the N + 1 query problem.
More details read in official Laravel documentation.
List of the most common eager loaded relations:
$comment = Comment::query() ->with([ 'loveReactant.reactions.reacter.reacterable', 'loveReactant.reactions.type', 'loveReactant.reactionCounters', 'loveReactant.reactionTotal', ]) ->get();
Updated over 2 years ago