mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:34:04 +00:00
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Stancl\Tenancy\Concerns\HasTenantOptions;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
class Run extends Command
|
|
{
|
|
use HasTenantOptions;
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Run a command for tenant(s)';
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'tenants:run {commandname : The artisan command.}
|
|
{--tenants=* : The tenant(s) to run the command for. Default: all}';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
tenancy()->runForMultiple($this->getTenants(), function ($tenant) {
|
|
$this->line("Tenant: {$tenant->getTenantKey()}");
|
|
|
|
Artisan::call($this->argument('commandname'));
|
|
$this->comment('Command output:');
|
|
$this->info(Artisan::output());
|
|
});
|
|
}
|
|
}
|