form->fill(); } public function dehydrate(): void { Artisan::call('config:clear'); Artisan::call('cache:clear'); } protected function getFormSchema(): array { return [ Wizard::make([ RequirementsStep::make(), EnvironmentStep::make(), DatabaseStep::make(), RedisStep::make() ->hidden(fn (Get $get) => $get('env.SESSION_DRIVER') != 'redis' && $get('env.QUEUE_CONNECTION') != 'redis' && $get('env.CACHE_STORE') != 'redis'), AdminUserStep::make(), ]) ->persistStepInQueryString() ->submitAction(new HtmlString(Blade::render(<<<'BLADE' Finish BLADE))), ]; } protected function getFormStatePath(): ?string { return 'data'; } protected function hasUnsavedDataChangesAlert(): bool { return true; } public function submit() { try { $inputs = $this->form->getState(); // Write variables to .env file $variables = array_get($inputs, 'env'); $this->writeToEnvironment($variables); // Clear config cache Artisan::call('config:clear'); // Run migrations Artisan::call('migrate', [ '--force' => true, '--seed' => true, '--database' => $variables['DB_CONNECTION'], ]); if (!$this->hasCompletedMigrations()) { throw new Exception('Migrations didn\'t run successfully. Double check your database configuration.'); } // Create first admin user $userData = array_get($inputs, 'user'); $userData['root_admin'] = true; $user = app(UserCreationService::class)->handle($userData); // Install setup complete $this->writeToEnvironment(['APP_INSTALLER' => 'false']); $this->rememberData(); Notification::make() ->title('Successfully Installed') ->success() ->send(); auth()->loginUsingId($user->id); return redirect('/admin'); } catch (Exception $exception) { report($exception); Notification::make() ->title('Installation Failed') ->body($exception->getMessage()) ->danger() ->persistent() ->send(); } } }