ToggleColumn restore action

Hi, I'm trying to make my togglecolumn restore or softdelete after change, is it possible?
No description
13 Replies
Vp
Vp9mo ago
Do you have any error?
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
Yes
No description
Vp
Vp9mo ago
can you show your code
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
No description
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
You need to see just the Resource or Model too? I just added a ToggleColumn, it seems Filament tries to update "deleted_at" to 0. But I have no idea how to make this toggle restore this row.
Vp
Vp9mo ago
ToggleColumn update boolean (true/false). I don't think you can update another column (not boolean column)
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
sad 😦
Vp
Vp9mo ago
My suggestions: Make boolean column like is_deleted and update that column using toggleColumn, and you can use ->afterStateUpdated() to update the deleted_at column..
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
I was thinking to make something like this... It seems is the only one solution
Vp
Vp9mo ago
Something like
Tables\Columns\ToggleColumn::make('is_deleted')
->label('Delete')
->afterStateUpdated(function ($record, $state) {
$record->update([
'deleted_at' => $state ? now() : null,
]);
}),
Tables\Columns\ToggleColumn::make('is_deleted')
->label('Delete')
->afterStateUpdated(function ($record, $state) {
$record->update([
'deleted_at' => $state ? now() : null,
]);
}),
maybe
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
thank you very much Ill do that @Vp I found a solution through mutators.
Yosef Bnei Noach
Yosef Bnei NoachOP9mo ago
No description
Vp
Vp9mo ago
Nice
Want results from more Discord servers?
Add your server