mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
wip
This commit is contained in:
@@ -55,6 +55,8 @@ trait CanGroupRecords
|
||||
|
||||
$group->applyEagerLoading($query);
|
||||
|
||||
return $group->orderQuery($query, $this->getTableGroupingDirection() ?? 'asc');
|
||||
$group->orderQuery($query, $this->getTableGroupingDirection() ?? 'asc');
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use Closure;
|
||||
use DateTimeInterface;
|
||||
use Filament\Support\Components\Component;
|
||||
use Filament\Support\Contracts\HasLabel as LabelInterface;
|
||||
use Filament\Tables\Columns\Concerns\InteractsWithTableQuery;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -18,8 +17,6 @@ use Illuminate\Support\Arr;
|
||||
|
||||
class Group extends Component
|
||||
{
|
||||
use InteractsWithTableQuery;
|
||||
|
||||
protected ?string $column;
|
||||
|
||||
protected ?Closure $getDescriptionFromRecordUsing = null;
|
||||
@@ -457,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