Simplify destroy method and update list

This commit is contained in:
Marcus Moore 2024-07-16 17:17:45 -07:00
parent eba494ad8c
commit f58e3114a2
No known key found for this signature in database

View file

@ -523,23 +523,22 @@ class Importer extends Component
public function destroy($id)
{
// TODO: why don't we just do File::find($id)? This seems dumb.
foreach ($this->files as $file) {
if ($id == $file->id) {
if (Storage::delete('private_uploads/imports/' . $file->file_path)) {
$file->delete();
$this->authorize('import');
$import = Import::findOrFail($id);
if (Storage::delete('private_uploads/imports/' . $import->file_path)) {
$import->delete();
$this->message = trans('admin/hardware/message.import.file_delete_success');
$this->message_type = 'success';
return;
} else {
$this->message = trans('admin/hardware/message.import.file_delete_error');
$this->message_type = 'danger';
}
}
}
unset($this->files);
return;
}
$this->message = trans('admin/hardware/message.import.file_delete_error');
$this->message_type = 'danger';
}
public function clearMessage()