Update child assets to reflect asset parent location (#7458)

This commit is contained in:
snipe 2019-12-04 16:19:25 -08:00 committed by GitHub
parent 2fbbe430b5
commit ff8d98c97c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -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;
}

View file

@ -394,6 +394,12 @@ class AssetsController extends Controller
if ($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)]);