mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Handle deletions on the observer
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
c2fe3b5459
commit
1527679f4b
|
@ -70,15 +70,19 @@ class ConsumableObserver
|
||||||
{
|
{
|
||||||
|
|
||||||
$consumable->users()->detach();
|
$consumable->users()->detach();
|
||||||
|
$uploads = $consumable->uploads;
|
||||||
|
|
||||||
foreach ($consumable->uploads() as $file) {
|
foreach ($uploads as $file) {
|
||||||
try {
|
try {
|
||||||
Storage::disk('public')->delete('consumables/'.$file);
|
Storage::delete('private_uploads/consumables/'.$file->filename);
|
||||||
|
$file->delete();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::info($e);
|
Log::info($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Storage::disk('public')->delete('consumables/'.$consumable->image);
|
Storage::disk('public')->delete('consumables/'.$consumable->image);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -37,6 +37,25 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
<!-- total -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{{ trans('admin/components/general.total') }}</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<p class="form-control-static">{{ $consumable->qty }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- remaining -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">{{ trans('admin/components/general.remaining') }}</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<p class="form-control-static">{{ $consumable->numRemaining() }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- User -->
|
<!-- User -->
|
||||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true'])
|
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true'])
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@
|
||||||
@can('delete', $consumable)
|
@can('delete', $consumable)
|
||||||
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
|
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
|
||||||
@if ($consumable->deleted_at=='')
|
@if ($consumable->deleted_at=='')
|
||||||
<button class="btn btn-sm btn-block btn-danger delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $consumable->id]) }}" data-target="#dataConfirmModal">{{ trans('general.delete') }}
|
<button class="btn btn-sm btn-block btn-danger delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $consumable->name]) }}" data-target="#dataConfirmModal">{{ trans('general.delete') }}
|
||||||
</button>
|
</button>
|
||||||
<span class="sr-only">{{ trans('general.delete') }}</span>
|
<span class="sr-only">{{ trans('general.delete') }}</span>
|
||||||
@endif
|
@endif
|
||||||
|
|
Loading…
Reference in a new issue