uses numRemaining now

This commit is contained in:
Godfrey M 2023-04-06 10:05:17 -07:00
parent b038fe8f2e
commit 55943d8897

View file

@ -78,9 +78,11 @@ class AccessoryCheckoutController extends Controller
]);
$checkedout=DB::table('accessories_users')->where('accessory_id', '=', $accessory->id)->count();
$available=DB::table('accessories')->where('id', '=', $accessory->id)->first('qty');
$available= new Accessory();
if($checkedout >= $available->qty){
if($checkedout >= $available->numRemaining()){
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.checkout.unavailable'));
}