mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Disallow checkout asset to itself
This commit is contained in:
parent
103974cae4
commit
5e5ba54c3e
|
@ -460,8 +460,14 @@ class AssetsController extends Controller
|
||||||
$asset->location_id = ($target) ? $target->id : '';
|
$asset->location_id = ($target) ? $target->id : '';
|
||||||
|
|
||||||
} elseif (request('checkout_to_type')=='asset') {
|
} elseif (request('checkout_to_type')=='asset') {
|
||||||
|
|
||||||
|
if (request('assigned_asset') == $assetId) {
|
||||||
|
return redirect()->back()->with('error', 'You cannot check an asset out to itself.');
|
||||||
|
}
|
||||||
|
|
||||||
$target = Asset::where('id','!=',$assetId)->find(request('assigned_asset'));
|
$target = Asset::where('id','!=',$assetId)->find(request('assigned_asset'));
|
||||||
$asset->location_id = $target->rtd_location_id;
|
$asset->location_id = $target->rtd_location_id;
|
||||||
|
|
||||||
// Override with the asset's location_id if it has one
|
// Override with the asset's location_id if it has one
|
||||||
if ($target->location_id!='') {
|
if ($target->location_id!='') {
|
||||||
$asset->location_id = ($target) ? $target->location_id : '';
|
$asset->location_id = ($target) ? $target->location_id : '';
|
||||||
|
|
Loading…
Reference in a new issue