From 293abbd1d0c7e031de7b93cce0c1894a1a38ffbb Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 24 Jul 2024 17:49:38 +0100 Subject: [PATCH] Allow cloning of deleted assets Signed-off-by: snipe --- .../Controllers/Assets/AssetsController.php | 24 ++++++-------- resources/views/hardware/view.blade.php | 31 +++++++++---------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 475f93e273..8fecff7e12 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -576,26 +576,20 @@ class AssetsController extends Controller * @since [v1.0] * @return \Illuminate\Contracts\View\View */ - public function getClone($assetId = null) + public function getClone(Asset $asset) { - // Check if the asset exists - if (is_null($asset_to_clone = Asset::find($assetId))) { - // Redirect to the asset management page - return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist')); - } - - $this->authorize('create', $asset_to_clone); - - $asset = clone $asset_to_clone; - $asset->id = null; - $asset->asset_tag = ''; - $asset->serial = ''; - $asset->assigned_to = ''; + $this->authorize('create', $asset); + $cloned = clone $asset; + $cloned->id = null; + $cloned->asset_tag = ''; + $cloned->serial = ''; + $cloned->assigned_to = ''; + $cloned->deleted_at = ''; return view('hardware/edit') ->with('statuslabel_list', Helper::statusLabelList()) ->with('statuslabel_types', Helper::statusTypeList()) - ->with('item', $asset); + ->with('item', $cloned); } /** diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 674233f5a6..6e2b2175fb 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -36,7 +36,7 @@ @endif - +