https://github.com/postare/db-config
This Filament plugin enables you to create dynamic configuration pages for your Laravel project.
https://github.com/postare/db-config
configuration filament-plugin filamentadmin filamentphp laravel
Last synced: 3 months ago
JSON representation
This Filament plugin enables you to create dynamic configuration pages for your Laravel project.
- Host: GitHub
- URL: https://github.com/postare/db-config
- Owner: postare
- License: mit
- Created: 2024-01-23T08:57:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-22T09:11:54.000Z (over 1 year ago)
- Last Synced: 2025-03-28T09:11:13.362Z (3 months ago)
- Topics: configuration, filament-plugin, filamentadmin, filamentphp, laravel
- Language: PHP
- Homepage:
- Size: 143 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# DB CONFIG
[](https://packagist.org/packages/postare/db-config)
[](https://github.com/postare/db-config/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/postare/db-config/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/postare/db-config)This plugin simplifies configuration management in Filament projects, enabling the easy creation and management of
dynamic configuration pages. It offers:It includes a simple command to generate a new configuration page, and a flexible form schema to add the desired fields.
The package handles saving data to the database and retrieving it as needed.
This version has been tested on Laravel 10.x and Filament 3.x.
We look forward to your feedback and suggestions for future improvements.
> Tested on Laravel 10.x and Filament 3.x## Installation
Install the package via Composer:
Laravel 10
```bash
composer require postare/db-config:^2.0
```Laravel 11
```bash
composer require postare/db-config
```Publish and run the migrations:
```bash
php artisan vendor:publish --tag="db-config-migrations"
php artisan migrate
```## Usage
Create a configuration page using the following command along with the name of the page:
```bash
php artisan make:db_config website# or specify panel
php artisan make:db_config website panelname
```This will create a Filament Page and a corresponding view. Next, modify the page file to add the fields you wish to
display on the configuration page.Example:
```php
namespace App\Filament\Pages;use Filament\Forms\Form;
use Postare\DbConfig\AbstractPageSettings;
use Filament\Forms\Components\TextInput;class WebsiteSettingsPage extends AbstractPageSettings
{
public ?array $data = [];protected static ?string $title = 'Website Settings';
protected static ?string $navigationIcon = 'heroicon-o-globe-europe-africa';
protected ?string $subheading = 'Manage your website configurations here.';
protected static string $view = 'filament.config-pages.website';
protected function settingName(): string
{
return 'website';
}public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('site_name')->required(),
// Add more fields here
])
->statePath('data');
}
}
```No additional steps are required. The package handles saving data to the database and retrieving it as needed.
## Accessing Saved Configurations
You can access the configurations in the following ways:
```php
// *Recommended* Helper method with optional default value
db_config('website.site_name', 'default value')// Blade Directive
@db_config('website.site_name')// Static Class
\Postare\DbConfig\DbConfig::get('website.site_name', 'default value');
```## License
This package is open-sourced software licensed under the MIT License.