Filament overriding withCount ?
Hi everyone ! I'm currently trying to add a "tickets_count" attribute on a "users" relationship to use it with AND without Filament. So my relationship looks like this:
The problem is that when I use this relationship in a Relation Manager, my withCount call is not taken in account. It seems Filament is actually overriding my selected attributes (which could be quite logical). Is there any way to solve this ?
7 Replies
What does your Relation Manager look like?
Here's the full code:
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 😅
Which is not very convenientTables\Columns\TextColumn::make('tickets_count')->counts('tickets')
should be all you needOr with the query you applied:
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 ?
You could try something like this: