Update in the license seat the user that the asset with that license have assigned

This commit is contained in:
Ivan Nieto Vivanco 2022-03-21 15:06:43 -06:00
parent 820f0a7f04
commit 319d816002
2 changed files with 16 additions and 0 deletions

View file

@ -111,6 +111,13 @@ class AssetCheckinController extends Controller
$checkin_at = $request->input('checkin_at');
}
if(!empty($asset->licenseseats->all())){
foreach ($asset->licenseseats as $seat){
$seat->assigned_to = null;
$seat->save();
}
}
// Get all pending Acceptances for this asset and delete them
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
[Asset::class],

View file

@ -80,6 +80,15 @@ class AssetCheckoutController extends Controller
$asset->status_id = $request->get('status_id');
}
if(!empty($asset->licenseseats->all())){
if(request('checkout_to_type') == 'user') {
foreach ($asset->licenseseats as $seat){
$seat->assigned_to = $target->id;
$seat->save();
}
}
}
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) {
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success'));
}