mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:34:04 +00:00
Update command that use tenants
This commit is contained in:
parent
f92b682eb3
commit
60fb9b8e54
6 changed files with 22 additions and 22 deletions
|
|
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue