#FileUpload
6 messages · Page 1 of 1 (latest)
Don't tell me it can be solved with this:
protected function getActions(): array
{
return [
Actions\DeleteAction::make()
->after(function (YourModel $record) {
// delete single
if ($record->photo) {
Storage::disk('public')->delete($record->photo);
}
// delete multiple
if ($record->galery) {
foreach ($record->galery as $ph) Storage::disk('public')->delete($ph);
}
}),
];
}
Yep, that should work.
Might be better in an observer though in case you need to reuse it. Let the model delete its files instead of the form.
Yup, your alternative also seems to have better performance.