mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 08:44:03 +00:00
[2.2.0] Use Tenant Run in console commands (#205)
* Utilize Tenant Run in commands * Apply fixes from StyleCI
This commit is contained in:
parent
b4caaaed51
commit
7389f44de9
4 changed files with 23 additions and 48 deletions
|
|
@ -49,21 +49,15 @@ class Migrate extends MigrateCommand
|
|||
return;
|
||||
}
|
||||
|
||||
$originalTenant = tenancy()->getTenant();
|
||||
tenancy()->all($this->option('tenants'))->each(function ($tenant) {
|
||||
$this->line("Tenant: {$tenant['id']}");
|
||||
|
||||
$this->input->setOption('database', $tenant->getConnectionName());
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
// Migrate
|
||||
parent::handle();
|
||||
|
||||
tenancy()->endTenancy();
|
||||
$tenant->run(function () {
|
||||
// Migrate
|
||||
parent::handle();
|
||||
});
|
||||
});
|
||||
|
||||
if ($originalTenant) {
|
||||
tenancy()->initialize($originalTenant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue