PHPackages                             ngankt2/filament-db-config-encrypt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. ngankt2/filament-db-config-encrypt

ActiveLibrary[Admin Panels](/categories/admin)

ngankt2/filament-db-config-encrypt
==================================

A Filament plugin for database-backed application settings and editable content, with caching and easy page generation.

v1.0.9(6mo ago)11.6k↓68.7%MITPHPPHP ^8.3

Since Sep 16Pushed 6mo agoCompare

[ Source](https://github.com/ngankt2/filament-db-config-security)[ Packagist](https://packagist.org/packages/ngankt2/filament-db-config-encrypt)[ RSS](/packages/ngankt2-filament-db-config-encrypt/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependencies (5)Versions (11)Used By (0)

Filament DB Config Encrypt
==========================

[](#filament-db-config-encrypt)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a2b7f8d2d5ea9dca5b65e8592024729c8220e1c05123cadde5f917dbefffb78e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e67616e6b74322f66696c616d656e742d64622d636f6e6669672d656e63727970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngankt2/filament-db-config-encrypt)[![Total Downloads](https://camo.githubusercontent.com/14659fed6e264f931b308c9d484f3b5ef1ffc62f79bb0872c1878bade984d523/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e67616e6b74322f66696c616d656e742d64622d636f6e6669672d656e63727970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ngankt2/filament-db-config-encrypt)[![License](https://camo.githubusercontent.com/a6354e9ff3e77ff00f70a0f1163834a06b79d8758d5c225ade704f79e048901f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e67616e6b74322f66696c616d656e742d64622d636f6e6669672d656e63727970742e7376673f7374796c653d666c61742d737175617265)](https://github.com/ngankt2/filament-db-config-security/blob/main/LICENSE)

A Filament plugin for managing database-backed application settings and editable content with caching and encryption support. It provides an Artisan command to generate settings pages and a helper function to retrieve settings in Blade templates or PHP code.

This project is a fork of . I only retrieved the source code to customize and use it privately, including renaming namespaces and adding several scenarios for encrypting data before storage.

Special thanks to the original author for their great work.

Features
--------

[](#features)

- **Database-Backed Settings**: Store and manage application settings in a database table.
- **Encryption Support**: Optionally encrypt settings for enhanced security.
- **Caching**: Cache settings with configurable TTL for performance optimization.
- **Filament Integration**: Generate Filament settings pages with a single Artisan command.
- **Helper Function**: Easily access settings in Blade templates or PHP code using the `db_config()` helper.
- **Flexible Grouping**: Organize settings into groups for better management.
- **Customizable Views**: Support for custom Blade views or a default view for settings pages.

Requirements
------------

[](#requirements)

- PHP: ^8.2
- Laravel: ^10.0 or ^11.0 or ^12.0
- Filament: ^3.0 or ^4.0
- ngankt2/laravel-helper: ^1.0

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require ngankt2/filament-db-config-encrypt
```

After installation, publish the configuration file and run the migrations:

```
php artisan vendor:publish --provider="Ngankt2\DbConfig\DbConfigServiceProvider"
php artisan migrate
```

This will create a `db_config` table in your database to store settings.

Configuration
-------------

[](#configuration)

The configuration file is located at `config/db-config.php`. Below is an example configuration:

```
return [
    'table_name' => 'db_config', // The database table to store settings
    'encrypt' => true, // Enable encryption for stored settings
    'cache' => [
        'prefix' => 'db-config', // Cache key prefix
        'ttl' => 60, // Cache TTL in minutes (0 for no expiration)
    ],
];
```

```
# .env example for encryption keys
ENCRYPT_DB_OTHER=YOUR_KEY_HERE
```

- `table_name`: The name of the database table to store settings.
- `encrypt`: Set to `true` to encrypt settings before storing them in the database.
- `cache.prefix`: The prefix for cache keys.
- `cache.ttl`: Time-to-live for cached settings in minutes. Set to `0` to cache indefinitely.

Usage
-----

[](#usage)

### Generating a Settings Page

[](#generating-a-settings-page)

Use the provided Artisan command to generate a Filament settings page:

```
php artisan make:db-config
```

This command will:

- Create a settings page class (e.g., `app/Filament/Admin/Clusters/SettingsCluster/Pages/GeneralSettings.php`).
- Optionally create a Blade view if you choose to use a custom view.
- Support clusters for organizing settings pages.

The generated page extends `Ngankt2\DbConfig\AbstractPageSettings` and includes methods to define the settings group, default data, and form schema.

### Defining Settings

[](#defining-settings)

Edit the generated settings page to define the form schema and default data. For example:

```
