F
Filament6mo ago
bruh

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
No description
1 Reply
LeandroFerreira
LeandroFerreira6mo ago
try updateStateUsing
Want results from more Discord servers?
Add your server