Skip to content

Commit

Permalink
Check for location_id being set before trying to set it on checkout v…
Browse files Browse the repository at this point in the history
…ia API
  • Loading branch information
snipe committed Apr 6, 2020
1 parent 0d3c18d commit 8939444
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,16 +616,14 @@ public function checkout(AssetCheckoutRequest $request, $asset_id)
$target = Asset::where('id','!=',$asset_id)->find(request('assigned_asset'));
$asset->location_id = $target->rtd_location_id;
// Override with the asset's location_id if it has one
if ($target->location_id!='') {
$asset->location_id = ($target) ? $target->location_id : '';
}
$asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : '';
$error_payload['target_id'] = $request->input('assigned_asset');
$error_payload['target_type'] = 'asset';

} elseif (request('checkout_to_type')=='user') {
// Fetch the target and set the asset's new location_id
$target = User::find(request('assigned_user'));
$asset->location_id = ($target) ? $target->location_id : '';
$asset->location_id = (($target) && (isset($target->location_id))) ? $target->location_id : '';
$error_payload['target_id'] = $request->input('assigned_user');
$error_payload['target_type'] = 'user';
}
Expand Down

0 comments on commit 8939444

Please sign in to comment.