1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-16 05:04:03 +00:00

phpstan, global_cache, resolver improvements, InitializationHelpers trait

This commit is contained in:
Samuel Štancl 2022-09-29 02:47:13 +02:00
parent fd65cf1754
commit 87212e5390
35 changed files with 170 additions and 231 deletions

View file

@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Commands;
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\Events\DatabaseRolledBack;
@ -14,25 +13,10 @@ use Stancl\Tenancy\Events\RollingBackDatabase;
class Rollback extends RollbackCommand
{
use HasATenantsOption, DealsWithMigrations, ExtendsLaravelCommand;
use HasATenantsOption, ExtendsLaravelCommand;
protected static function getTenantCommandName(): string
{
return 'tenants:rollback';
}
/**
* The console command description.
*
* @var string
*/
protected $description = 'Rollback migrations for tenant(s).';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(Migrator $migrator)
{
parent::__construct($migrator);
@ -40,10 +24,7 @@ class Rollback extends RollbackCommand
$this->specifyTenantSignature();
}
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
foreach (config('tenancy.migration_parameters') as $parameter => $value) {
if (! $this->input->hasParameterOption($parameter)) {
@ -52,7 +33,7 @@ class Rollback extends RollbackCommand
}
if (! $this->confirmToProceed()) {
return;
return 1;
}
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
@ -65,5 +46,12 @@ class Rollback extends RollbackCommand
event(new DatabaseRolledBack($tenant));
});
return 0;
}
protected static function getTenantCommandName(): string
{
return 'tenants:rollback';
}
}