Added checkin on delete to API

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-10-01 14:30:34 +01:00
parent 5823197e6f
commit 27ba641aa5

View file

@ -780,9 +780,16 @@ class AssetsController extends Controller
if ($asset = Asset::find($id)) {
$this->authorize('delete', $asset);
DB::table('assets')
->where('id', $asset->id)
->update(['assigned_to' => null]);
if ($asset->assignedTo) {
$target = $asset->assignedTo;
$checkin_at = date('Y-m-d H:i:s');
$originalValues = $asset->getRawOriginal();
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on delete', $checkin_at, $originalValues));
DB::table('assets')
->where('id', $asset->id)
->update(['assigned_to' => null]);
}
$asset->delete();