Laravel Output Prediction Hard +35 XP
Eager Loading
What problem does with() solve?
LaravelRead-only
$posts = Post::with("author")->get();What is the output?
Show answer and explanation
Answer: N+1 query problem
with() eager loads the relationship in 2 queries instead of 1 + N queries (one per post).
Hint: How many queries without with()?
What this challenge tests
Output Prediction in Laravel: eloquent, eager-loading.