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:
parent
fbe43fbb04
commit
4f8d892481
20 changed files with 19 additions and 83 deletions
38
src/Concerns/TenantAwareCommand.php
Normal file
38
src/Concerns/TenantAwareCommand.php
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue