Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.