mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge branch 'pr/10662' into 3.x
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user