3.9 KiB
name, description
| name | description |
|---|---|
| filament-db-config | Creates database-backed settings pages and config pages with filament-db-config or db-config package. Activates when creating settings page, config page, configuration page, or when user mentions db-config, db_config, DbConfig, database settings, dynamic configuration, runtime config, storing settings in database. ALWAYS use php artisan make:db-config command to scaffold. NEVER create files manually. NEVER create tests. |
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
// Standard helper $siteName = db_config('website.site_name', 'Default');// Safe helper (for early boot, migrations, service providers) $siteName = safe_db_config('website.site_name', 'Default');
Blade directive:
@db_config('website.site_name', 'Default')
Writing Values
use Inerba\DbConfig\DbConfig;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:
protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-cog'; protected static ?string $navigationGroup = 'Settings'; protected static ?int $navigationSort = 10;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