diff --git a/src/Traits/TenantAwareCommand.php b/src/Traits/TenantAwareCommand.php index 7a38d2fd..1eee7af4 100644 --- a/src/Traits/TenantAwareCommand.php +++ b/src/Traits/TenantAwareCommand.php @@ -6,13 +6,22 @@ use Symfony\Component\Console\Output\OutputInterface; trait TenantAwareCommand { - protected function execute(InputInterface $input, OutputInterface $output): void + /** @return mixed|void */ + protected function execute(InputInterface $input, OutputInterface $output) { + $tenants = $this->getTenants(); + + if (count($tenants) === 1) { + return $tenants[0]->run(function () { + return $this->laravel->call([$this, 'handle']); + }); + } + array_map(function (Tenant $tenant) { $tenant->run(function () { $this->laravel->call([$this, 'handle']); }); - }, $this->getTenants()); + }, $tenants); } /**