SpatieTags filter
This is probably a problem more Laravel than Filament.... But maybe someone can tell me how to create a filter for SpatieTags?
The name column is json type, so I try as below and only have sequence numbers instead of names in Select (1,2,3,4)
SelectFilter::make('tags')
->relationship('tags', 'id')
->options(Tag::getWithType('company_types')
->pluck('name->pl', 'id')
)
6 Replies
change
->relationship('tags', 'name')
and remove options()
or remove ->relationship()
and keep only ->options()
..if I use relationship() then names are as raw json, second option throws error Column not found: 1054 Unknown column 'tags' in 'where clause'.
I think here the relationship should be used but how to get to the correct name? This way ->relationship('tags', 'name->pl') doesn't work.
I am not sure whether it will work or not but try like this
->relationship('tags', 'name', fn (Builder $query) => $query->name->pl)
Or ->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name),
, this is from form select, don't know if exist in filterUnfortunately that doesn't work either 😦
Pretty sure this is a non fixed bug with filament
There should be a gitbub issue with a workaround
I can't find anything on github about this issue.