© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
Jerome V

How to put action on toggleColumn?

Is it possible to do like this? I want to use the toggle to block user the case is the
blocked_at = timestamp
blocked_by = unsignedBigInt

 Tables\Columns\ToggleColumn::make('blocked_at')
                    ->label('Block')
                    ->sortable()
                    ->onColor('success')
                    ->offColor('danger')
                    ->action(function ($record, $state) {
                        
                        $blocked_at = $state ? now() : null;
                        $blocked_by = $state ? auth()->id() : null;

                        $record->update([
                            'blocked_at' => $blocked_at,
                            'blocked_by' => $blocked_by,
                        ]);
                    }),
 Tables\Columns\ToggleColumn::make('blocked_at')
                    ->label('Block')
                    ->sortable()
                    ->onColor('success')
                    ->offColor('danger')
                    ->action(function ($record, $state) {
                        
                        $blocked_at = $state ? now() : null;
                        $blocked_by = $state ? auth()->id() : null;

                        $record->update([
                            'blocked_at' => $blocked_at,
                            'blocked_by' => $blocked_by,
                        ]);
                    }),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ToggleColumn Action
FilamentFFilament / ❓┊help
3y ago
ToggleColumn restore action
FilamentFFilament / ❓┊help
2y ago
Action in ToggleColumn
FilamentFFilament / ❓┊help
3y ago
ToggleColumn and Modal Confirmation (Action?)
FilamentFFilament / ❓┊help
3y ago