1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 03:54:04 +00:00
tenancy/src/Commands/Run.php
Samuel Stancl e0990a438c
Laravel 13.24 support (fix #1474) (#1476)
- We conditionally use either $signature + specifyParameters() in the
  newer versions or just $name in the older versions. There doesn't
  appear to be a single solution that'd work in both versions, likely
  having to do with the constructor override in the trait and how the
  specifyParameters() method behaves differently in this class between
  versions
- Remove unnecessary options from the Run command (the trait adds those)
- Not directly related: make HasTenantOptions accept ...$args
- Unrelated: remove phpstan ignore in TenancyServiceProvider
2026-08-04 20:49:48 -07:00

38 lines
1,015 B
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel;
use Stancl\Tenancy\Concerns\HasTenantOptions;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\ConsoleOutput;
class Run extends Command
{
use HasTenantOptions;
protected $description = 'Run a command for tenant(s)';
protected $signature = 'tenants:run {commandname : The artisan command.}';
public function handle(): int
{
/** @var string $commandName */
$commandName = $this->argument('commandname');
$stringInput = new StringInput($commandName);
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use ($stringInput) {
$this->components->info("Tenant: {$tenant->getTenantKey()}");
$this->getLaravel()
->make(Kernel::class)
->handle($stringInput, new ConsoleOutput);
});
return 0;
}
}