Small fixes for cli tool

This commit is contained in:
snipe 2020-07-09 20:43:13 -07:00
parent 25e53d8c7f
commit cf0dd5bbad
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -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);
}
}