Skip to content

Commit

Permalink
Asking for command and tenant
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk committed May 17, 2020
1 parent d74f83a commit 93882af
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Commands/TenantsArtisanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
Expand Down

0 comments on commit 93882af

Please sign in to comment.