The error message indicates that the settings properties are missing when trying to load the GeneralSettings class. This usually happens when the settings are not properly saved in the database or the settings migration has not been run.
Here are the steps to resolve this issue:
-
Ensure Settings Migration Exists and is Run: Make sure you have created a settings migration for the
GeneralSettingsclass. If not, you can create one using the following command:php artisan make:settings-migration create_general_settingsThis will create a migration file in the
database/settingsdirectory. Open the migration file and ensure it includes all the properties defined in yourGeneralSettingsclass.use Spatie\LaravelSettings\Migrations\SettingsMigration; return new class extends SettingsMigration { public function up(): void { $this->migrator->add('general.tagline', 'Poetry'); $this->migrator->add('general.name', 'Laravel'); $this->migrator->add('general.favicon', 'favicon.ico'); $this->migrator->add('general.logo_light', 'logo.png'); $this->migrator->add('general.logo_dark', 'logo-dark.png'); $this->migrator->add('general.custom_css', 'some text'); $this->migrator->add('general.custom_js', 'some more text'); $this->migrator->add('general.admin_email', '[email protected]'); } };After creating the migration, run it using:
php artisan migrate -
Check Database Settings: Ensure that the settings are correctly stored in the database. You can check the
settingstable (or the table specified in your configuration) to verify that the settings are present. -
Clear Cache: If you have caching enabled for settings, clear the cache to ensure the latest settings are loaded.
php artisan cache:clear -
Verify Configuration: Ensure that your
config/settings.phpfile is correctly configured to use theGeneralSettingsclass.return [ 'settings' => [ 'general' => \App\Settings\GeneralSettings::class, ], // other configurations... ]; -
Update Filament Page: Ensure that your Filament page is correctly referencing the settings and form fields.
namespace App\Filament\Pages; use App\Settings\GeneralSettings; use Filament\Forms; use Filament\Forms\Form; use Filament\Pages\SettingsPage; use Filament\Forms\Components\TextInput; class AppSettings extends SettingsPage { protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth'; protected static string $settings = GeneralSettings::class; public function form(Form $form): Form { return $form ->schema([ TextInput::make('name'), TextInput::make('tagline') ->label('Tagline') ->required(), TextInput::make('favicon'), TextInput::make('logo_light'), TextInput::make('logo_dark'), TextInput::make('custom_css'), TextInput::make('custom_js'), TextInput::make('admin_email') ->label('Admin Email'), ]); } }
By following these steps, you should be able to resolve the issue with missing properties in the GeneralSettings class.