New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nested Repeater Eager Loading #9802
Conversation
Checks if the relationship is already eagerly loaded, returning itself to avoid querying the database again and causing an N+1 query problem.
Your previous implementation would have broken |
would sortBy fix the orderColumn Problem? elseif (
$this->getModelInstance()->relationLoaded($relationshipName) &&
(! $this->modifyRelationshipQueryUsing) &&
filled($orderColumn)
){
return $this->cachedExistingRecords = $this->getRecord()->{$relationshipName}->sortBy($orderColumn)->mapWithKeys(
fn (Model $item): array => ["record-{$item[$relatedKeyName]}" => $item],
);
} That would take the eager loading into account & still work, wouldn't it? |
It would fix it, but I don't know why you would want to do that, when you can chain it onto the |
In my case it does not work. However, I have applied orderBy('sort') directly to the relationship |
Feature for orderColumn + Eager Loading
Checks if the relationship is already eagerly loaded, returning itself to avoid querying the database again and causing an N+1 query problem.
Issue/Bug Description: #9776