Skythrew
Skythrew
FFilament
Created by Skythrew on 4/27/2025 in #❓┊help
Filament overriding withCount ?
That's actually what I thought I should be using too but isn't there any way to use the field which is added directly by the relationship in order to avoid writing the same code in my table as in my model ?
11 replies
FFilament
Created by Skythrew on 4/27/2025 in #❓┊help
Filament overriding withCount ?
Which is not very convenient
11 replies
FFilament
Created by Skythrew on 4/27/2025 in #❓┊help
Filament overriding withCount ?
And for now the only way I found to "bypass" Filament override is to add the withCount in the modifyQueryUsing table method as you can see 😅
11 replies
FFilament
Created by Skythrew on 4/27/2025 in #❓┊help
Filament overriding withCount ?
Here's the full code:
class UsersRelationManager extends RelationManager
{
protected static string $relationship = 'users';

protected static ?string $title = 'Clients';

public function table(Table $table): Table
{
return $table
->modifyQueryUsing(function (Builder $query) {
/*$query->withCount(['tickets as tickets_count' => function (Builder $query) {
$query->forSession($this->getOwnerRecord())->withoutCanceled();
}]);*/
})
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('tickets_count')
]);
}
}
class UsersRelationManager extends RelationManager
{
protected static string $relationship = 'users';

protected static ?string $title = 'Clients';

public function table(Table $table): Table
{
return $table
->modifyQueryUsing(function (Builder $query) {
/*$query->withCount(['tickets as tickets_count' => function (Builder $query) {
$query->forSession($this->getOwnerRecord())->withoutCanceled();
}]);*/
})
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('tickets_count')
]);
}
}
11 replies