AI-generated Eloquent relationship loop causing massive N+1 performance degradation and unindexed foreign key lookups.
$posts = Post::all();
foreach ($posts as $post) {
echo $post->user->name;
}
Demonstrate deep domain expertise against superficial AI prompting.
"I know database design and Laravel inside and out. Calling $post->user inside a loop without eager loading fires N+1 separate queries. I'd replace this with Post::with('user')->get() and ensure foreign keys have composite indexes."