-
-
Notifications
You must be signed in to change notification settings - Fork 489
Expand file tree
/
Copy pathRun.php
More file actions
40 lines (29 loc) · 1.15 KB
/
Run.php
File metadata and controls
40 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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.}
{--tenants=* : The tenant(s) to run the command for. Default: all}
{--skip-tenants=* : The tenant(s) to skip}';
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;
}
}