F
Filament2mo ago
Andi

Repeater Soft-Delete

Hey guys, does anybody know if the Repeater Component supports soft deletes? Delete Button makes a delete, but doesn't gives an option to force delete or restore if the record is only soft deleted. Docs don't say anything about it. Maybe I just don't see it, but I think there is no method for that.
10 Replies
LeandroFerreira
LeandroFerreira2mo ago
The repeater delete action will remove the item in the DB when the form is submitted. I guess if you want to manage this behavior, you should consider observing it in your model with laravel observers.
Andi
Andi2mo ago
The repeater delete action does a "simple" delete, not a force delete. Therefore the item doesn't gets deleted, it only gets soft deleted. Yes I could make a obverser which then force deletes it, but that kinda makes soft delete obsolete then.
Andi
Andi2mo ago
No description
LeandroFerreira
LeandroFerreira2mo ago
When would you like to force delete?
Andi
Andi2mo ago
When the item is not needed anymore 100%, so kinda at any time. Also I could just make a resource for the relation and then do restore / force delete there, this just makes the workflow ugly. Delete on the repeater item should still soft delete the item, but then 2 actions would be nice to restore / force delete the repeater item.
LeandroFerreira
LeandroFerreira2mo ago
extra actions I think
Andi
Andi2mo ago
Tried to implement it now using extra actions, almost works. I have hidden() logic on each action
->hidden(function (array $arguments, Forms\Components\Repeater $component) : bool {
$itemData = $component->getRawItemState($arguments['item']);

return $itemData['deleted_at'] !== null;
})
->hidden(function (array $arguments, Forms\Components\Repeater $component) : bool {
$itemData = $component->getRawItemState($arguments['item']);

return $itemData['deleted_at'] !== null;
})
Those hidden methods don't seem to be live, adding live() to the repeater component doesn't change anything. Do you know how I can trigger to reevaluate hidden() function on the other action fields?
awcodes
awcodes2mo ago
If you remove the item from the repeater then it’s no longer in the state, so there’s no way to even reference it to do a force delete.
Andi
Andi2mo ago
But I don't remove the item from repeater. I disabled the default delete action. My delete action just does ->delete(), no unset from state
awcodes
awcodes2mo ago
Ah, my bad.