Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-22T09:11:54.000Z (9 months ago)
- Last Synced: 2024-09-28T11:45:46.459Z (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
[![Latest Version on Packagist](https://img.shields.io/packagist/v/postare/db-config.svg?style=flat-square)](https://packagist.org/packages/postare/db-config)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/postare/db-config/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/postare/db-config/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/postare/db-config/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/postare/db-config/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/postare/db-config.svg?style=flat-square)](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.![Screenshot](https://raw.githubusercontent.com/postare/db-config/main/screenshot.png)
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.