adds unavailable message to overcheckout

This commit is contained in:
Godfrey M 2023-04-05 10:00:39 -07:00
parent ead5293ee0
commit b038fe8f2e
2 changed files with 9 additions and 0 deletions

View file

@ -77,6 +77,14 @@ class AccessoryCheckoutController extends Controller
'note' => $request->input('note'),
]);
$checkedout=DB::table('accessories_users')->where('accessory_id', '=', $accessory->id)->count();
$available=DB::table('accessories')->where('id', '=', $accessory->id)->first('qty');
if($checkedout >= $available->qty){
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable'));
}
DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
event(new CheckoutableCheckedOut($accessory, $user, Auth::user(), $request->input('note')));

View file

@ -24,6 +24,7 @@ return array(
'checkout' => array(
'error' => 'Accessory was not checked out, please try again',
'success' => 'Accessory checked out successfully.',
'unavailable' => 'Accessory is not available for checkout. Check quantity available',
'user_does_not_exist' => 'That user is invalid. Please try again.'
),