mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:14:03 +00:00
Correct the tenant order in Run command
This commit is contained in:
parent
cd37528399
commit
0ee54da29c
1 changed files with 12 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ namespace Stancl\Tenancy\Commands;
|
|||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Concerns\HasTenantOptions;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
|
@ -34,7 +35,17 @@ class Run extends Command
|
|||
public function handle()
|
||||
{
|
||||
$argvInput = $this->ArgvInput();
|
||||
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use ($argvInput) {
|
||||
$tenants = $this->getTenants();
|
||||
|
||||
if ($this->option('tenants')) {
|
||||
// $this->getTenants() doesn't return tenants in the same order as the tenants passed in the tenants option
|
||||
// Map the passed tenant keys to the fetched tenant models to correct the order
|
||||
$tenants = array_map(function (string $tenantKey) use ($tenants) {
|
||||
return $tenants->filter(fn(Tenant $tenant) => $tenant->getTenantKey() === $tenantKey)->first();
|
||||
}, $this->option('tenants'));
|
||||
}
|
||||
|
||||
tenancy()->runForMultiple($tenants, function ($tenant) use ($argvInput) {
|
||||
$this->line("Tenant: {$tenant->getTenantKey()}");
|
||||
|
||||
$this->getLaravel()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue