mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Cleaned up
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
be17ef4047
commit
ad85f8be2f
|
@ -136,29 +136,28 @@ class ImageUploadRequest extends Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove Current image if exists
|
// Remove Current image if exists
|
||||||
$item = $this->deleteExistingImage($item, $form_fieldname, $path, $db_fieldname);
|
$item = $this->deleteExistingImage($item, $path, $db_fieldname);
|
||||||
$item->{$db_fieldname} = $file_name;
|
$item->{$db_fieldname} = $file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the user isn't uploading anything new but wants to delete their old image, do so
|
// If the user isn't uploading anything new but wants to delete their old image, do so
|
||||||
} elseif ($this->input('image_delete') == '1') {
|
} elseif ($this->input('image_delete') == '1') {
|
||||||
$item = $this->deleteExistingImage($item, $form_fieldname, $path, $db_fieldname);
|
$item = $this->deleteExistingImage($item, $path, $db_fieldname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteExistingImage($item, $form_fieldname = 'image', $path = null, $db_fieldname = 'image') {
|
public function deleteExistingImage($item, $path = null, $db_fieldname = 'image') {
|
||||||
|
|
||||||
\Log::error('DELETING '.$form_fieldname);
|
if ($item->{$db_fieldname}!='') {
|
||||||
|
try {
|
||||||
try {
|
Storage::disk('public')->delete($path.'/'.$item->{$db_fieldname});
|
||||||
Storage::disk('public')->delete($path.'/'.$item->{$db_fieldname});
|
$item->{$db_fieldname} = null;
|
||||||
$item->{$db_fieldname} = null;
|
} catch (\Exception $e) {
|
||||||
\Log::error('deleted successfully');
|
Log::debug($e);
|
||||||
} catch (\Exception $e) {
|
}
|
||||||
Log::debug($e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
|
|
Loading…
Reference in a new issue