F
Filament2y ago
dyo

Having Toggle in table header

How to have a toggle class in table headerActions?
6 Replies
ZedoX
ZedoX2y ago
What are you trying to do, what is your end goal?
dyo
dyoOP2y ago
I want to turn the action button in first image, to toggle like in the second image
dyo
dyoOP2y ago
anyone can help me?
Dennis Koch
Dennis Koch2y ago
No. Actions can only be Actions.
Patrick Boivin
Maybe you can use a regular button as a "toggle"... something like this :
Action::make('enable')
->label(__('Enable'))
->button()
->action(function () {
// Do something

auth()->user()->update(['has_feature_enabled' => true]);
})
->visible(fn () => ! (auth()->user()->has_feature_enabled)),
Action::make('disable')
->label(__('Disable'))
->button()
->color('danger')
->action(function () {
// Do something

auth()->user()->update(['has_feature_enabled' => false]);
})
->visible(fn () => auth()->user()->has_feature_enabled),
Action::make('enable')
->label(__('Enable'))
->button()
->action(function () {
// Do something

auth()->user()->update(['has_feature_enabled' => true]);
})
->visible(fn () => ! (auth()->user()->has_feature_enabled)),
Action::make('disable')
->label(__('Disable'))
->button()
->color('danger')
->action(function () {
// Do something

auth()->user()->update(['has_feature_enabled' => false]);
})
->visible(fn () => auth()->user()->has_feature_enabled),
Want results from more Discord servers?
Add your server