Merge branch 'pr/10662' into 3.x

This commit is contained in:
Dan Harrin
2024-01-08 10:50:13 +00:00
2 changed files with 20 additions and 1 deletions
@@ -53,6 +53,10 @@ trait CanGroupRecords
return $query;
}
return $group->orderQuery($query, $this->getTableGroupingDirection() ?? 'asc');
$group->applyEagerLoading($query);
$group->orderQuery($query, $this->getTableGroupingDirection() ?? 'asc');
return $query;
}
}
+15
View File
@@ -454,4 +454,19 @@ class Group extends Component
{
return $this->isDate;
}
public function applyEagerLoading(EloquentBuilder $query): EloquentBuilder
{
if (! $this->getRelationship($query->getModel())) {
return $query;
}
$relationshipName = $this->getRelationshipName();
if (array_key_exists($relationshipName, $query->getEagerLoads())) {
return $query;
}
return $query->with([$relationshipName]);
}
}