1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-15 19:14:03 +00:00

Remove obsolete files, restructure

This commit is contained in:
Samuel Štancl 2020-05-21 15:54:35 +02:00
parent fbe43fbb04
commit 4f8d892481
20 changed files with 19 additions and 83 deletions

View file

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Concerns;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Stancl\Tenancy\Contracts\Tenant;
trait TenantAwareCommand
{
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
{
$tenants = $this->getTenants();
$exitCode = 0;
foreach ($tenants as $tenant) {
$result = (int) $tenant->run(function () {
return $this->laravel->call([$this, 'handle']);
});
if ($result !== 0) {
$exitCode = $result;
}
}
return $exitCode;
}
/**
* Get an array of tenants for which the command should be executed.
*
* @return Tenant[]|mixed
*/
abstract protected function getTenants();
}