From 3c05d6bbfeefb27b43156bc2d3ae77fb71161aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 8 Nov 2019 16:47:49 +0100 Subject: [PATCH] Return value when a single tenant is passed --- src/Traits/TenantAwareCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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); } /**