info(date('r').' Create Single Account...'); $this->createAccount(); } private function createAccount() { $settings = CompanySettings::defaults(); $settings->name = "Untitled Company"; $settings->currency_id = '1'; $settings->language_id = '1'; $account = Account::factory()->create(); $company = Company::factory()->create([ 'account_id' => $account->id, 'portal_domain' => config('ninja.app_url'), 'portal_mode' => 'domain', 'settings' => $settings, ]); $company->client_registration_fields = ClientRegistrationFields::generate(); $company->save(); $account->default_company_id = $company->id; $account->set_react_as_default_ap = true; $account->save(); $email = $this->option('email') ?? 'admin@example.com'; $password = $this->option('password') ?? 'changeme!'; $user = User::factory()->create([ 'account_id' => $account->id, 'email' => $email, 'password' => Hash::make($password), 'confirmation_code' => $this->createDbHash(config('database.default')), 'email_verified_at' => now(), 'first_name' => 'New', 'last_name' => 'User', 'phone' => '', ]); $company_token = new CompanyToken(); $company_token->user_id = $user->id; $company_token->company_id = $company->id; $company_token->account_id = $account->id; $company_token->name = 'User Token'; $company_token->token = Str::random(64); $company_token->is_system = true; $company_token->save(); $user->companies()->attach($company->id, [ 'account_id' => $account->id, 'is_owner' => 1, 'is_admin' => 1, 'is_locked' => 0, 'notifications' => CompanySettings::notificationDefaults(), 'settings' => null, ]); (new CreateCompanyPaymentTerms($company, $user))->handle(); (new CreateCompanyTaskStatuses($company, $user))->handle(); (new VersionCheck())->handle(); } }