Updating state after filtering

Cant find out if it's currently possible, where after filtering, I update the state and tooltip of values.
Filter::make('languages')
->form([
Select::make('locale')
->options(Locales::all()->pluck('title', 'locale'))
->selectablePlaceholder(false),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['locale'],
function (Builder $query, $state) {
if ($state == null || $state == "en") {
return $query;
}
return $query->whereHas('locales', fn (Builder $query) => $query->where('locales_offer.locale', $state));
}
);
}),
Filter::make('languages')
->form([
Select::make('locale')
->options(Locales::all()->pluck('title', 'locale'))
->selectablePlaceholder(false),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['locale'],
function (Builder $query, $state) {
if ($state == null || $state == "en") {
return $query;
}
return $query->whereHas('locales', fn (Builder $query) => $query->where('locales_offer.locale', $state));
}
);
}),
When I filter a different language, I want to update the fields with the translations, and add a tooltip with the originals
7 Replies
Jamie Cee
Jamie CeeOP12mo ago
Any ideas?
Dennis Koch
Dennis Koch12mo ago
Just add the tooltip to your columns with a Closure that has a condition on your selected locale
Jamie Cee
Jamie CeeOP12mo ago
What about the value itself? As if I have the filter as spanish, I want my title and description fields to show the spanish equilalent?
Dennis Koch
Dennis Koch12mo ago
Why aren't you using the LanguageSwitch that Filament provides? It would handle it all for you
Jamie Cee
Jamie CeeOP12mo ago
As we've been looking into a manual build just at work, so was just playing around with all of this
Jamie Cee
Jamie CeeOP12mo ago
Filament
Language Switch by Bezhan Salleh - Plugins - Filament
Zero config Language Switch(Changer/Localizer) plugin for Filamentphp Admin
Dennis Koch
Dennis Koch12mo ago
Filament
Spatie Translatable by Filament - Filament
Filament support for Spatie's Laravel Translatable package.
Want results from more Discord servers?
Add your server