form->fill([ 'site_name' => is_string($siteName) ? $siteName : config('app.name'), 'site_logo' => is_string($siteLogo) || is_null($siteLogo) ? $siteLogo : null, 'primary_color' => is_string($primaryColor) ? $primaryColor : '#3b82f6', 'secondary_color' => is_string($secondaryColor) ? $secondaryColor : '#8b5cf6', 'accent_color' => is_string($accentColor) ? $accentColor : '#10b981', 'site_description' => is_string($siteDescription) || is_null($siteDescription) ? $siteDescription : '', 'contact_email' => is_string($contactEmail) || is_null($contactEmail) ? $contactEmail : '', 'maintenance_mode' => is_bool($maintenanceMode) ? $maintenanceMode : false, 'enable_registration' => is_bool($enableRegistration) ? $enableRegistration : false, ]); } public function form(Form $form): Form { return $form ->schema([ Forms\Components\Section::make('General Settings') ->schema([ Forms\Components\TextInput::make('site_name') ->label('Site Name') ->required() ->maxLength(255), Forms\Components\FileUpload::make('site_logo') ->label('Site Logo') ->image() ->directory('logos') ->visibility('public'), Forms\Components\Textarea::make('site_description') ->label('Site Description') ->rows(3) ->maxLength(500), Forms\Components\TextInput::make('contact_email') ->label('Contact Email') ->email() ->maxLength(255), ]), Forms\Components\Section::make('Color Scheme') ->schema([ Forms\Components\ColorPicker::make('primary_color') ->label('Primary Color'), Forms\Components\ColorPicker::make('secondary_color') ->label('Secondary Color'), Forms\Components\ColorPicker::make('accent_color') ->label('Accent Color'), ]) ->columns(3), Forms\Components\Section::make('System') ->schema([ Forms\Components\Toggle::make('enable_registration') ->label('Enable User Registration') ->helperText('Allow new users to register. When disabled, only admins can create users.'), Forms\Components\Toggle::make('maintenance_mode') ->label('Maintenance Mode') ->helperText('Enable to put the site in maintenance mode'), ]), ]) ->statePath('data'); } protected function getFormActions(): array { return [ Action::make('save') ->label('Save Settings') ->submit('save'), ]; } public function save(): void { $data = $this->form->getState(); Setting::set('site_name', $data['site_name'] ?? ''); Setting::set('site_logo', $data['site_logo'] ?? ''); Setting::set('primary_color', $data['primary_color'] ?? '#3b82f6'); Setting::set('secondary_color', $data['secondary_color'] ?? '#8b5cf6'); Setting::set('accent_color', $data['accent_color'] ?? '#10b981'); Setting::set('site_description', $data['site_description'] ?? ''); Setting::set('contact_email', $data['contact_email'] ?? ''); Setting::set('maintenance_mode', $data['maintenance_mode'] ?? false, 'boolean'); Setting::set('enable_registration', $data['enable_registration'] ?? false, 'boolean'); Notification::make() ->title('Settings saved successfully') ->success() ->send(); } }