-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Description
Just started using this package ❤️
The alert says:
Found the following N+1 queries in this request:
Model: App\Balance => Relation: statement - You should add "with('statement')" to eager-load this relation.
Although it is great that the package tries to give advice (You should add "with('statement')" to eager-load this relation.
), this might be "misleading":
What is actually happening in my code is a loop over $account->balances->groupBy('statement_id')
(as $balances
) where $balances[0]->statement
is called. In this case the correct solution was adding $account->load('balances.statement');
Maybe there is a way to formulate the alert in a more code independent way that keeps it useful?
Metadata
Metadata
Assignees
Labels
No labels