© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
m_svyrzhevskiy

afterStateUpdated doesn't work

Here's my resource to manage permissions using spatie library:

return $table
->columns([
TextColumn::make('name')
->label('Permission\Role')
->sortable()
->searchable(),
...Role::all()->map(fn($role) => CheckboxColumn::make('role_' . $role->id)
->label($role->name)
->getStateUsing(fn ($record) => $record->roles->contains($role))
->toggleable()
->afterStateUpdated(function ($state, $record) use ($role) {
DB::transaction(function () use ($state, $record, $role) {
if ($state) {
$role->givePermissionTo($record);
} else {
$role->revokePermissionTo($record);
}
});
}))->toArray(),
])


For some reason, when i change checkbox state, it still trying to update a column in Permissions table instead of do what my callback do.
I'm new in fillament, so I would appreciate any help
image.png
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

TagsInput afterStateUpdated() doesnt work
FilamentFFilament / ❓┊help
3y ago
ExportBulkAction doesn't work
FilamentFFilament / ❓┊help
2y ago
afterStateHydrated() doesn't work?
FilamentFFilament / ❓┊help
3y ago
Scrollable doesn't work
FilamentFFilament / ❓┊help
3y ago