# DB Config - Filament Database Settings Manager
## Introduction
DB Config is a lightweight Filament plugin that provides a database-backed key/value store for managing application settings and editable content in Laravel applications. The package eliminates the need for custom Eloquent models or complex configuration classes, storing all data as JSON in a single database table with transparent caching. It's designed for both traditional configuration values (site name, contact info, maintenance mode) and dynamic page content (homepage sections, landing page blocks, about text).
The plugin seamlessly integrates with Filament's form system, supporting any form field component including third-party ones. It provides a command-line generator to scaffold settings pages, simple helper functions for reading and writing values, and a Blade directive for template access. All data is cached automatically with configurable TTL, and cache invalidation happens transparently when values are updated. The package requires no external dependencies beyond Filament and Laravel, making it a minimal-footprint solution for runtime-editable settings.
## Installation
```bash
# Install via Composer
composer require inerba/filament-db-config
# Publish migration
php artisan vendor:publish --tag="db-config-migrations"
# Run migration to create db_config table
php artisan migrate
# Optional: Publish configuration file
php artisan vendor:publish --tag="db-config-config"
```
## Configuration File
```php
'db_config',
// Cache settings
'cache' => [
'prefix' => 'db-config', // Cache key prefix
'ttl' => null, // null = cache forever, or set minutes
],
];
```
## Generate Settings Pages
```bash
# Interactive mode (prompts for name and panel)
php artisan make:db-config
# With arguments: create WebsiteSettings page in default panel
php artisan make:db-config Website
# Specify panel: create WebsiteSettings page in Admin panel
php artisan make:db-config Website Admin
```
## Reading Configuration Values - Helper Function
```php
set('website.contact', [
'email' => 'info@example.com',
'phone' => '+1234567890',
'address' => ['city' => 'New York', 'zip' => '10001']
]);
$email = db_config('website.contact.email', 'default@example.com');
// Returns: 'info@example.com'
$city = db_config('website.contact.address.city', 'Unknown');
// Returns: 'New York'
$country = db_config('website.contact.address.country', 'USA');
// Returns: 'USA' (default, since 'country' doesn't exist)
```
## Reading Configuration Values - Static Class Method
```php
'Acme Inc.', 'contact_email' => 'info@acme.test', ...]
// Get last updated timestamp for a group
$lastUpdate = DbConfig::getGroupLastUpdatedAt('website', 'F j, Y, g:i a', 'America/New_York');
// Returns: 'October 23, 2025, 3:45 pm' or null if not found
```
## Reading Configuration Values - Facade
```php
{{ db_config('website.site_name', 'My Site') }}
{{-- Using Blade directive --}}