A free open source IT asset/license management system
Update child assets to reflect asset parent location (#7458)
snipeff8d98c97c38
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex 86a68aa686..708d596dda 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -525,6 +525,10 @@ class AssetsController extends Controller$location = $target->location_id;} elseif (($request->filled('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) {$location = $target->location_id;++ Asset::where('assigned_type', '\\App\\Models\\Asset')->where('assigned_to', $id)+ ->update(['location_id' => $target->location_id]);+} elseif (($request->filled('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) {$location = $target->id;}diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.phpindex 20f3a22854..fe8c2b4d02 100755--- a/app/Http/Controllers/AssetsController.php+++ b/app/Http/Controllers/AssetsController.php@@ -394,6 +394,12 @@ class AssetsController extends Controllerif ($asset->save()) {++ // Update any assigned assets with the new location_id from the parent asset++ Asset::where('assigned_type', '\\App\\Models\\Asset')->where('assigned_to', $asset->id)+ ->update(['location_id' => $asset->location_id]);+// Redirect to the new asset page\Session::flash('success', trans('admin/hardware/message.update.success'));return response()->json(['redirect_url' => route("hardware.show", $assetId)]);