diff --git a/src/Commands/InitCommand.php b/src/Commands/InitCommand.php index 0275ff9..0cadf6f 100644 --- a/src/Commands/InitCommand.php +++ b/src/Commands/InitCommand.php @@ -323,10 +323,12 @@ protected function runMigrations(): void protected function createAdminUser(string $kebabName, string $serviceKey = '', string $serviceName = ''): array { - $adminEmail = when(empty($serviceKey), "admin@{$kebabName}.com", "admin.{$serviceKey}@{$kebabName}.com"); + $isServiceAdmin = (!empty($serviceKey) && !empty($serviceName)); + + $adminEmail = when($isServiceAdmin, "admin.{$serviceKey}@{$kebabName}.com", "admin@{$kebabName}.com"); $defaultPassword = substr(md5(uniqid()), 0, 8); - $serviceLabel = when(!empty($serviceName), " for {$serviceName}"); + $serviceLabel = when($isServiceAdmin, " for {$serviceName}"); $adminCredentials = [ 'email' => $this->ask("Please enter admin email{$serviceLabel}", $adminEmail), @@ -334,11 +336,11 @@ protected function createAdminUser(string $kebabName, string $serviceKey = '', s ]; if ($this->authType === AuthTypeEnum::None) { - $adminCredentials['name'] = $this->ask("Please enter admin name{$serviceLabel}", "{$serviceName} Admin"); + $adminCredentials['name'] = $this->ask("Please enter admin name{$serviceLabel}", when($isServiceAdmin, "{$serviceName} Admin", 'Admin')); $adminCredentials['role_id'] = $this->ask("Please enter admin role id{$serviceLabel}", RoleEnum::Admin->value); } - if (empty($serviceName)) { + if (!$isServiceAdmin) { $this->adminCredentials = $adminCredentials; }