Я создал команду laravel как:
class CreateFirstUserCommand extends Command
{
protected $signature = 'firsttenant:create {name}';
protected $description = 'Creates first user in database with name';
public function handle()
{
$name = $this->argument('name');
$website = new Website();
app(WebsiteRepository::class)->create($website);
$hostname = new Hostname;
$hostname->fqdn = $name.'.site.me';
$hostname = app(HostnameRepository::class)->create($hostname);
app(HostnameRepository::class)->attach($hostname, $website);
$tenancy = app(Environment::class);
$tenancy->hostname($hostname);
// resolves $hostname as currently active hostname
$tenancy->hostname();
// switches the tenant and reconfigures the app
$tenancy->tenant($website);
// resolves $website
$tenancy->website();
// resolves $website
$tenancy->tenant();
$tenancy->identifyHostname();
sleep(10);
$role = Role::create(['name' => 'tenant']);
$permission = Permission::create(['name' => 'all']);
$user= new User();
$user->name = $name;
$user->email = 'admin@'.$name.'.site.me';
$user->password = Hash::make('12344321');
$user->assignRole('tenant');
$user->save();
}
}
Я вызываю эту команду из консоли как:
php artisan firsttenant: create alpha
и работает нормально, как и ожидалось, но когда я вызываю это из кода как:
Artisan :: call ('firsttenant: create', ['name' => $ name]);
Не выполняет никаких действий.