1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 18:34:04 +00:00

Improve writing

This commit is contained in:
lukinovec 2022-07-26 08:16:44 +02:00
parent 371b3836b6
commit 677fdb23b9
3 changed files with 7 additions and 7 deletions

View file

@ -37,7 +37,7 @@ return [
/** /**
* Pending tenancy config. * Pending tenants config.
* This is useful if you're looking for a way to always have a tenant ready to be used. * This is useful if you're looking for a way to always have a tenant ready to be used.
*/ */
'pending' => [ 'pending' => [

View file

@ -37,7 +37,7 @@ class ClearPendingTenants extends Command
// We compare the original expiration date to the new one to check if the new one is different later // We compare the original expiration date to the new one to check if the new one is different later
$originalExpirationDate = $expirationDate->copy()->toImmutable(); $originalExpirationDate = $expirationDate->copy()->toImmutable();
// If the 'all' option is given, skip the expiry date configuration // Skip the time constraints if the 'all' option is given
if (! $this->option('all')) { if (! $this->option('all')) {
if ($olderThanDays = $this->option('older-days') ?? config('tenancy.pending.older_than_days')) { if ($olderThanDays = $this->option('older-days') ?? config('tenancy.pending.older_than_days')) {
$expirationDate->subDays($olderThanDays); $expirationDate->subDays($olderThanDays);
@ -48,7 +48,7 @@ class ClearPendingTenants extends Command
} }
} }
$deletedPendingCount = tenancy() $deletedTenantCount = tenancy()
->query() ->query()
->onlyPending() ->onlyPending()
->when($originalExpirationDate->notEqualTo($expirationDate), function (Builder $query) use ($expirationDate) { ->when($originalExpirationDate->notEqualTo($expirationDate), function (Builder $query) use ($expirationDate) {
@ -59,6 +59,6 @@ class ClearPendingTenants extends Command
->delete() ->delete()
->count(); ->count();
$this->info($deletedPendingCount . ' pending ' . str('tenant')->plural($deletedPendingCount) . ' deleted.'); $this->info($deletedTenantCount . ' pending ' . str('tenant')->plural($deletedTenantCount) . ' deleted.');
} }
} }

View file

@ -13,14 +13,14 @@ class CreatePendingTenants extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'tenants:pending {--count= : The number of tenants to be in a pending state}'; protected $signature = 'tenants:pending-create {--count= : The number of pending tenants to be created}';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Create tenants until the pending count is achieved.'; protected $description = 'Create pending tenants.';
/** /**
* Execute the console command. * Execute the console command.
@ -36,7 +36,7 @@ class CreatePendingTenants extends Command
while ($pendingTenantCount < $maxPendingTenantCount) { while ($pendingTenantCount < $maxPendingTenantCount) {
tenancy()->model()::createPending(); tenancy()->model()::createPending();
// Fetch the count each time to prevent creating too many tenants // Fetching the pending tenant count in each iteration prevents creating too many tenants
// If pending tenants are being created somewhere else while running this command // If pending tenants are being created somewhere else while running this command
$pendingTenantCount = $this->getPendingTenantCount(); $pendingTenantCount = $this->getPendingTenantCount();