From 93882af984dff1873446118e5545a23d6ec6bd42 Mon Sep 17 00:00:00 2001 From: Eduard Lupacescu Date: Sun, 17 May 2020 14:12:38 +0300 Subject: [PATCH] Asking for command and tenant --- src/Commands/TenantsArtisanCommand.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Commands/TenantsArtisanCommand.php b/src/Commands/TenantsArtisanCommand.php index 2ab1aea..f0c7580 100644 --- a/src/Commands/TenantsArtisanCommand.php +++ b/src/Commands/TenantsArtisanCommand.php @@ -3,6 +3,7 @@ namespace Spatie\Multitenancy\Commands; use Illuminate\Console\Command; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Artisan; use Spatie\Multitenancy\Models\Tenant; @@ -14,11 +15,17 @@ public function handle() { $tenantQuery = Tenant::query(); - if ($tenantIds = $this->option('tenant')) { - $tenantQuery = $tenantQuery->whereIn('id', $tenantIds); + if (!$artisanCommand = $this->argument('artisanCommand')) { + $artisanCommand = $this->ask('Command to run?'); } - $artisanCommand = $this->argument('artisanCommand'); + if (!$tenantIds = $this->option('tenant')) { + $tenantIds = $this->ask('What tenant ID? Nothing for all tenants.'); + } + + if ($tenantIds) { + $tenantQuery->whereIn('id', Arr::wrap($tenantIds)); + } $tenantQuery ->cursor()