F
Filament14mo ago
qcol

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
Vp
Vp14mo ago
change ->relationship('tags', 'name') and remove options() or remove ->relationship() and keep only ->options()..
qcol
qcolOP14mo ago
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.
No description
Vp
Vp14mo ago
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 filter
qcol
qcolOP14mo ago
Unfortunately that doesn't work either 😦
DanielvdSpoel
DanielvdSpoel14mo ago
Pretty sure this is a non fixed bug with filament There should be a gitbub issue with a workaround
qcol
qcolOP14mo ago
I can't find anything on github about this issue.
Want results from more Discord servers?
Add your server