From 60fb9b8e54bf2f8527db6285c30552bf754e0f17 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Fri, 22 Jul 2022 15:10:23 +0200 Subject: [PATCH] Update command that use tenants --- src/Commands/Migrate.php | 8 ++++---- src/Commands/MigrateFresh.php | 8 ++++---- src/Commands/Rollback.php | 8 ++++---- src/Commands/Run.php | 8 ++++---- src/Commands/Seed.php | 8 ++++---- tests/Etc/AddUserCommand.php | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Commands/Migrate.php b/src/Commands/Migrate.php index efc6d090..03e5409a 100644 --- a/src/Commands/Migrate.php +++ b/src/Commands/Migrate.php @@ -9,13 +9,13 @@ use Illuminate\Database\Console\Migrations\MigrateCommand; use Illuminate\Database\Migrations\Migrator; use Stancl\Tenancy\Concerns\DealsWithMigrations; use Stancl\Tenancy\Concerns\ExtendsLaravelCommand; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; use Stancl\Tenancy\Events\DatabaseMigrated; use Stancl\Tenancy\Events\MigratingDatabase; class Migrate extends MigrateCommand { - use HasATenantsOption, DealsWithMigrations, ExtendsLaravelCommand; + use HasTenantOptions, DealsWithMigrations, ExtendsLaravelCommand; protected $description = 'Run migrations for tenant(s)'; @@ -46,7 +46,7 @@ class Migrate extends MigrateCommand return; } - tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + tenancy()->runForMultiple($this->getTenants(), function ($tenant) { $this->line("Tenant: {$tenant->getTenantKey()}"); event(new MigratingDatabase($tenant)); @@ -55,6 +55,6 @@ class Migrate extends MigrateCommand parent::handle(); event(new DatabaseMigrated($tenant)); - }, $this->withPending()); + }); } } diff --git a/src/Commands/MigrateFresh.php b/src/Commands/MigrateFresh.php index ab98292c..ab243968 100644 --- a/src/Commands/MigrateFresh.php +++ b/src/Commands/MigrateFresh.php @@ -6,12 +6,12 @@ namespace Stancl\Tenancy\Commands; use Illuminate\Console\Command; use Stancl\Tenancy\Concerns\DealsWithMigrations; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; use Symfony\Component\Console\Input\InputOption; final class MigrateFresh extends Command { - use HasATenantsOption, DealsWithMigrations; + use HasTenantOptions, DealsWithMigrations; /** * The console command description. @@ -34,7 +34,7 @@ final class MigrateFresh extends Command */ public function handle() { - tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + tenancy()->runForMultiple($this->getTenants(), function ($tenant) { $this->info('Dropping tables.'); $this->call('db:wipe', array_filter([ '--database' => 'tenant', @@ -47,7 +47,7 @@ final class MigrateFresh extends Command '--tenants' => [$tenant->getTenantKey()], '--force' => true, ]); - }, $this->withPending()); + }); $this->info('Done.'); } diff --git a/src/Commands/Rollback.php b/src/Commands/Rollback.php index d6b14d04..1f443238 100644 --- a/src/Commands/Rollback.php +++ b/src/Commands/Rollback.php @@ -8,13 +8,13 @@ use Illuminate\Database\Console\Migrations\RollbackCommand; use Illuminate\Database\Migrations\Migrator; use Stancl\Tenancy\Concerns\DealsWithMigrations; use Stancl\Tenancy\Concerns\ExtendsLaravelCommand; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; use Stancl\Tenancy\Events\DatabaseRolledBack; use Stancl\Tenancy\Events\RollingBackDatabase; class Rollback extends RollbackCommand { - use HasATenantsOption, DealsWithMigrations, ExtendsLaravelCommand; + use HasTenantOptions, DealsWithMigrations, ExtendsLaravelCommand; protected static function getTenantCommandName(): string { @@ -55,7 +55,7 @@ class Rollback extends RollbackCommand return; } - tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + tenancy()->runForMultiple($this->getTenants(), function ($tenant) { $this->line("Tenant: {$tenant->getTenantKey()}"); event(new RollingBackDatabase($tenant)); @@ -64,6 +64,6 @@ class Rollback extends RollbackCommand parent::handle(); event(new DatabaseRolledBack($tenant)); - }, $this->withPending()); + }); } } diff --git a/src/Commands/Run.php b/src/Commands/Run.php index cedf1ca5..f8ab2089 100644 --- a/src/Commands/Run.php +++ b/src/Commands/Run.php @@ -5,11 +5,11 @@ declare(strict_types=1); namespace Stancl\Tenancy\Commands; use Illuminate\Console\Command; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; class Run extends Command { - use HasATenantsOption; + use HasTenantOptions; /** * The console command description. * @@ -31,7 +31,7 @@ class Run extends Command */ public function handle() { - tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + tenancy()->runForMultiple($this->getTenants(), function ($tenant) { $this->line("Tenant: {$tenant->getTenantKey()}"); $callback = function ($prefix = '') { @@ -51,6 +51,6 @@ class Run extends Command // Run command $this->call($this->argument('commandname'), array_merge($arguments, $options)); - }, $this->withPending()); + }); } } diff --git a/src/Commands/Seed.php b/src/Commands/Seed.php index 944acab8..85bd6246 100644 --- a/src/Commands/Seed.php +++ b/src/Commands/Seed.php @@ -6,13 +6,13 @@ namespace Stancl\Tenancy\Commands; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Console\Seeds\SeedCommand; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; use Stancl\Tenancy\Events\DatabaseSeeded; use Stancl\Tenancy\Events\SeedingDatabase; class Seed extends SeedCommand { - use HasATenantsOption; + use HasTenantOptions; /** * The console command description. @@ -48,7 +48,7 @@ class Seed extends SeedCommand return; } - tenancy()->runForMultiple($this->option('tenants'), function ($tenant) { + tenancy()->runForMultiple($this->getTenants(), function ($tenant) { $this->line("Tenant: {$tenant->getTenantKey()}"); event(new SeedingDatabase($tenant)); @@ -57,6 +57,6 @@ class Seed extends SeedCommand parent::handle(); event(new DatabaseSeeded($tenant)); - }, $this->withPending()); + }); } } diff --git a/tests/Etc/AddUserCommand.php b/tests/Etc/AddUserCommand.php index 46e1fcbb..99901301 100644 --- a/tests/Etc/AddUserCommand.php +++ b/tests/Etc/AddUserCommand.php @@ -6,12 +6,12 @@ namespace Stancl\Tenancy\Tests\Etc; use Illuminate\Console\Command; use Illuminate\Support\Str; -use Stancl\Tenancy\Concerns\HasATenantsOption; +use Stancl\Tenancy\Concerns\HasTenantOptions; use Stancl\Tenancy\Concerns\TenantAwareCommand; class AddUserCommand extends Command { - use TenantAwareCommand, HasATenantsOption; + use TenantAwareCommand, HasTenantOptions; /** * The name and signature of the console command.