Filament DB Config
When to Apply
Activate this skill when:
- Creating settings pages or config pages
- Working with db-config, db_config(), DbConfig
- User mentions database settings, dynamic configuration
- User asks to store configuration in database
Documentation
Use search-docs for Filament form components and patterns. Do NOT rely on training data — always check the installed Filament version documentation.
Critical Workflow
STEP 1: Always scaffold with artisan command first:
php artisan make:db-config HomeSeo --no-interaction
IMPORTANT: Only pass the Name. NEVER add a second argument like "admin" or "panel". The command only takes one argument.
This generates app/Filament/Pages/{Name}Settings.php. The generator automatically adds "Settings" suffix.
STEP 2: Edit the generated file to add your fields in the form() method.
NEVER create files manually.
NEVER create tests. Tests are NOT needed for settings pages.
After Scaffolding
Edit the generated page class to customize the form() method:
public function form(Schema $schema): Schema { return $schema ->components([ TextInput::make('site_name')->label('Site Name'), TextInput::make('contact_email')->label('Contact Email'), Toggle::make('maintenance_mode')->label('Maintenance Mode'), ]) ->statePath('data'); }
Default Values
Override getDefaultData() to pre-fill the form:
Reading Values
// Safe helper (for early boot, migrations, service providers) $siteName = safe_db_config('website.site_name', 'Default');
Blade directive:
Writing Values
DbConfig::set('website.site_name', 'Acme Inc.'); $group = DbConfig::getGroup('website');
IMPORTANT: Do NOT Create Tests
Do NOT create any test files for db-config settings pages. Tests are NOT needed and NOT wanted unless the user explicitly asks for them.
Filament Property Types
When setting Filament page properties, always use the correct union types:
NEVER write protected static string $navigationIcon — always include | BackedEnum | null.
Common Mistakes
- NEVER create files manually — always run
php artisan make:db-configfirst - NEVER create tests — no tests for settings pages unless explicitly requested
- NEVER use
config()— always usedb_config()helper - NEVER forget
statePath('data')— forms must have->statePath('data') - NEVER forget union types — navigationIcon must be
string | BackedEnum | null
Source: inerba/filament-db-config — distributed by TomeVault.