From 3a6e673418fd0f3dea0315d0b562f5ec74e0c4df Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 28 Nov 2022 14:41:18 +0100 Subject: [PATCH] Remove `--all` option from ClearPendingTenants --- src/Commands/ClearPendingTenants.php | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/Commands/ClearPendingTenants.php b/src/Commands/ClearPendingTenants.php index 19d31195..17a1fab6 100644 --- a/src/Commands/ClearPendingTenants.php +++ b/src/Commands/ClearPendingTenants.php @@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Builder; class ClearPendingTenants extends Command { protected $signature = 'tenants:pending-clear - {--all : Override the default settings and deletes all pending tenants} {--older-than-days= : Deletes all pending tenants older than the amount of days} {--older-than-hours= : Deletes all pending tenants older than the amount of hours}'; @@ -24,28 +23,22 @@ class ClearPendingTenants extends Command // We compare the original expiration date to the new one to check if the new one is different later $originalExpirationDate = $expirationDate->copy()->toImmutable(); - // Skip the time constraints if the 'all' option is given - if (! $this->option('all')) { - /** @var ?int $olderThanDays */ - $olderThanDays = $this->option('older-than-days'); + $olderThanDays = $this->option('older-than-days'); + $olderThanHours = $this->option('older-than-hours'); - /** @var ?int $olderThanHours */ - $olderThanHours = $this->option('older-than-hours'); + if ($olderThanDays && $olderThanHours) { + $this->line(" Cannot use '--older-than-days' and '--older-than-hours' together \n"); // todo@cli refactor all of these styled command outputs to use $this->components + $this->line('Please, choose only one of these options.'); - if ($olderThanDays && $olderThanHours) { - $this->line(" Cannot use '--older-than-days' and '--older-than-hours' together \n"); // todo@cli refactor all of these styled command outputs to use $this->components - $this->line('Please, choose only one of these options.'); + return 1; // Exit code for failure + } - return 1; // Exit code for failure - } + if ($olderThanDays) { + $expirationDate->subDays($olderThanDays); + } - if ($olderThanDays) { - $expirationDate->subDays($olderThanDays); - } - - if ($olderThanHours) { - $expirationDate->subHours($olderThanHours); - } + if ($olderThanHours) { + $expirationDate->subHours($olderThanHours); } $deletedTenantCount = tenancy()