how to fix tag name showing up in search box spatie/tags

Using Spatie/tags, when filtering, it shows the full json stored in the name field (See screenshot). The tag name should just be the value of the json object, not the entire thing.
->filters([
SelectFilter::make('tags')
->searchable()
->relationship('tags', 'name')
->options(fn () => Tag::all()->pluck('name', 'id')->toArray())
])
->filters([
SelectFilter::make('tags')
->searchable()
->relationship('tags', 'name')
->options(fn () => Tag::all()->pluck('name', 'id')->toArray())
])
No description
2 Replies
toeknee
toeknee3mo ago
You are storing as json for the language string, so you are wanting to actually translate it by the looks of it. You can use format state, but I would probably getAttributeUsing and return the value for the current langauge You also don't need ->options(fn () => Tag::all()->pluck('name', 'id')->toArray()) when using relationships
LeandroFerreira
LeandroFerreira3mo ago
could you remove options and try this?
->relationship('tags', fn (Component $livewire): string => 'name->'.$livewire->activeLocale)
->relationship('tags', fn (Component $livewire): string => 'name->'.$livewire->activeLocale)