1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-06 14:34:04 +00:00

Merge branch 'master' into stein-j-readied-tenant

This commit is contained in:
lukinovec 2022-09-28 09:48:24 +02:00
commit b56934674a
107 changed files with 976 additions and 734 deletions

View file

@ -5,8 +5,10 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Stancl\Tenancy\Concerns\HasTenantOptions;
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
class Run extends Command
{
@ -31,12 +33,27 @@ class Run extends Command
*/
public function handle()
{
tenancy()->runForMultiple($this->getTenants(), function ($tenant) {
$argvInput = $this->ArgvInput();
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use ($argvInput) {
$this->line("Tenant: {$tenant->getTenantKey()}");
Artisan::call($this->argument('commandname'));
$this->comment('Command output:');
$this->info(Artisan::output());
$this->getLaravel()
->make(Kernel::class)
->handle($argvInput, new ConsoleOutput);
});
}
/**
* Get command as ArgvInput instance.
*/
protected function ArgvInput(): ArgvInput
{
// Convert string command to array
$subCommand = explode(' ', $this->argument('commandname'));
// Add "artisan" as first parameter because ArgvInput expects "artisan" as first parameter and later removes it
array_unshift($subCommand, 'artisan');
return new ArgvInput($subCommand);
}
}