form->fill(); } protected function getFormSchema(): array { return [ Wizard::make([ RequirementsStep::make(), EnvironmentStep::make($this), DatabaseStep::make($this), RedisStep::make($this) ->hidden(fn (Get $get) => $get('env_general.SESSION_DRIVER') != 'redis' && $get('env_general.QUEUE_CONNECTION') != 'redis' && $get('env_general.CACHE_STORE') != 'redis'), AdminUserStep::make($this), CompletedStep::make(), ]) ->persistStepInQueryString() ->nextAction(fn (Action $action) => $action->keyBindings('enter')) ->submitAction(new HtmlString(Blade::render(<<<'BLADE' Finish BLADE))), ]; } protected function getFormStatePath(): ?string { return 'data'; } public function submit(): RedirectResponse { // Disable installer $this->writeToEnvironment(['APP_INSTALLED' => 'true']); // Login user $this->user ??= User::all()->filter(fn ($user) => $user->isRootAdmin())->first(); auth()->guard()->login($this->user, true); // Redirect to admin panel return redirect(Filament::getPanel('admin')->getUrl()); } public function writeToEnv(string $key): void { try { $variables = array_get($this->data, $key); $this->writeToEnvironment($variables); } catch (Exception $exception) { report($exception); Notification::make() ->title('Could not write to .env file') ->body($exception->getMessage()) ->danger() ->persistent() ->send(); throw new Halt('Error while writing .env file'); } Artisan::call('config:clear'); } public function runMigrations(string $driver): void { try { Artisan::call('migrate', [ '--force' => true, '--seed' => true, '--database' => $driver, ]); } catch (Exception $exception) { report($exception); Notification::make() ->title('Migrations failed') ->body($exception->getMessage()) ->danger() ->persistent() ->send(); throw new Halt('Error while running migrations'); } if (!$this->hasCompletedMigrations()) { Notification::make() ->title('Migrations failed') ->danger() ->persistent() ->send(); throw new Halt('Migrations failed'); } } public function createAdminUser(): void { try { $userData = array_get($this->data, 'user'); $userData['root_admin'] = true; $this->user = app(UserCreationService::class)->handle($userData); } catch (Exception $exception) { report($exception); Notification::make() ->title('Could not create admin user') ->body($exception->getMessage()) ->danger() ->persistent() ->send(); throw new Halt('Error while creating admin user'); } } }