From cf0dd5bbadef3689dd9110d96e7d060ddb5fc827 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 9 Jul 2020 20:43:13 -0700 Subject: [PATCH] Small fixes for cli tool --- app/Console/Commands/CheckoutLicenseToAllUsers.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index bf8941233..1421876da 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -51,7 +51,7 @@ class CheckoutLicenseToAllUsers extends Command } - if (!$license = License::find($license_id)->first()) { + if (!$license = License::where('id','=',$license_id)->first()) { $this->error('Invalid license ID'); return false; } @@ -69,11 +69,12 @@ class CheckoutLicenseToAllUsers extends Command foreach ($users as $user) { // If the license is valid, check that there is an available seat - if ($license->getAvailSeatsCountAttribute() < 1) { + if ($license->availCount()->count() < 1) { $this->error('ERROR: No available seats'); return false; } + $this->info($license->availCount()->count().' seats left'); // Get the seat ID $licenseSeat = $license->freeSeat(); @@ -89,7 +90,7 @@ class CheckoutLicenseToAllUsers extends Command // Log the checkout $licenseSeat->logCheckout('Checked out via cli tool', $user); - $this->info('License '.$license_id.' checked out to '.$user->username); + $this->info('License '.$license_id.' seat '.$licenseSeat->id.' checked out to '.$user->username); } }