From 6766237669af2e9bc03803c621068c1e2665b771 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 27 Jul 2022 13:01:09 +0200 Subject: [PATCH] Remove pending tenant clearing time constraints --- assets/config.php | 10 ---------- src/Commands/ClearPendingTenants.php | 8 ++++---- tests/PendingTenantsTest.php | 4 +--- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/assets/config.php b/assets/config.php index 39d5a5de..8b6a429d 100644 --- a/assets/config.php +++ b/assets/config.php @@ -52,16 +52,6 @@ return [ * This depends on the volume of tenants you're creating. */ 'count' => env('TENANCY_PENDING_COUNT', 5), - - /** - * You can define time constraints for automatically deleting unused - * pending tenants (schedule the `tenancy:pending-clear` command to make this work automatically). - * - * If both values are set to null, the time constraints won't be set and all pending tenants will be deleted. - */ - 'older_than_days' => env('TENANCY_PENDING_OLDER_THAN_DAYS', null), - - 'older_than_hours' => env('TENANCY_PENDING_OLDER_THAN_HOURS', null), ], /** diff --git a/src/Commands/ClearPendingTenants.php b/src/Commands/ClearPendingTenants.php index a96eaf00..6af98178 100644 --- a/src/Commands/ClearPendingTenants.php +++ b/src/Commands/ClearPendingTenants.php @@ -16,8 +16,8 @@ class ClearPendingTenants extends Command */ protected $signature = 'tenants:pending-clear {--all : Override the default settings and deletes all pending tenants} - {--older-days= : Deletes all pending tenants older than the amount of days} - {--older-hours= : Deletes all pending tenants older than the amount of hours}'; + {--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}'; /** * The console command description. @@ -39,11 +39,11 @@ class ClearPendingTenants extends Command // Skip the time constraints if the 'all' option is given if (! $this->option('all')) { - if ($olderThanDays = $this->option('older-days') ?? config('tenancy.pending.older_than_days')) { + if ($olderThanDays = $this->option('older-than-days')) { $expirationDate->subDays($olderThanDays); } - if ($olderThanHours = $this->option('older-hours') ?? config('tenancy.pending.older_than_hours')) { + if ($olderThanHours = $this->option('older-than-hours')) { $expirationDate->subHours($olderThanHours); } } diff --git a/tests/PendingTenantsTest.php b/tests/PendingTenantsTest.php index ff26e9b9..b30440b9 100644 --- a/tests/PendingTenantsTest.php +++ b/tests/PendingTenantsTest.php @@ -72,13 +72,11 @@ class PendingTenantsTest extends TestCase Artisan::call(CreatePendingTenants::class); - config(['tenancy.pending.older_than_days' => 2]); - tenancy()->model()->query()->onlyPending()->first()->update([ 'pending_since' => now()->subDays(5)->timestamp ]); - Artisan::call(ClearPendingTenants::class); + Artisan::call('tenants:pending-clear --older-than-days=2'); $this->assertCount(1, Tenant::onlyPending()->get()); }