josefo727/filament-general-settings
最新稳定版本:2.0.5
Composer 安装命令:
composer require josefo727/filament-general-settings
包简介
A Filament plugin for managing general settings in a Laravel application
README 文档
README
A Filament plugin for managing general settings in a Laravel application.
Features
- Manage general settings through a Filament interface
- Support for various data types (string, integer, float, boolean, array, json, date, time, datetime, url, email, emails, password)
- Dynamic form inputs based on data type
- Encryption support for password values
- Multilingual support (English and Spanish)
- Table prefix configuration
Requirements
- PHP 8.2 or higher
- Laravel 11.28 or higher
- Filament 4.0 or higher
Installation
-
Install the package via Composer:
composer require josefo727/filament-general-settings
-
Run the installation command:
php artisan filament-general-settings:install
-
Run the migrations:
php artisan migrate
Configuration
After installation, you can publish the configuration file:
php artisan vendor:publish --tag=filament-general-settings-config
This will create a filament-general-settings.php file in your config directory. You can customize the following options:
return [ // Table configuration 'table' => [ 'name' => 'general_settings', 'prefix' => env('FILAMENT_GENERAL_SETTINGS_TABLE_PREFIX', ''), ], // Encryption configuration 'encryption' => [ 'enabled' => true, 'key' => env('FILAMENT_GENERAL_SETTINGS_ENCRYPTION_KEY', 'some_default_key'), ], // Password display configuration 'show_passwords' => env('FILAMENT_GENERAL_SETTINGS_SHOW_PASSWORDS', false), // Navigation configuration 'navigation' => [ 'group' => 'Settings', 'icon' => 'heroicon-o-cog', 'sort' => 1, ], ];
Integration with Filament Admin Panel
Register the Plugin
To add the General Settings to your Filament Admin Panel, you need to register the plugin in your App\Providers\Filament\AdminPanelProvider:
use Josefo727\FilamentGeneralSettings\FilamentGeneralSettingsPlugin; // ... public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ FilamentGeneralSettingsPlugin::make(), // Other plugins... ]); }
Add Alias (Optional)
Laravel 10 and 11
For easier access to the GeneralSetting model without having to import it, you can add an alias in your config/app.php file:
'aliases' => [ // ... 'GeneralSetting' => Josefo727\FilamentGeneralSettings\Models\GeneralSetting::class, ],
Laravel 12
For Laravel 12, you can register the alias in your App\Providers\AppServiceProvider:
use Illuminate\Foundation\AliasLoader; use Josefo727\FilamentGeneralSettings\Models\GeneralSetting; public function register(): void { $loader = AliasLoader::getInstance(); $loader->alias('GeneralSetting', GeneralSetting::class); }
Usage
Accessing Settings
You can access settings in your application using the provided facade:
// Get a setting value $value = GeneralSetting::getValue('setting_name'); // Get a setting value with a default $value = GeneralSetting::getValue('setting_name', 'default_value'); // Using the helper function to get a setting value $value = getSetting('setting_name'); // Using the helper function to get a setting value with a default $value = getSetting('setting_name', 'default_value'); // Check if a setting exists if (GeneralSetting::has('setting_name')) { // Do something } // Set a setting value GeneralSetting::create([ 'name' => 'setting_name', 'value' => 'value', 'type' => 'string', 'description' => 'Description' ]); // Remove a setting GeneralSetting::remove('setting_name');
Data Types
The package supports the following data types:
string: Text valuesinteger: Integer valuesfloat: Floating point valuesboolean: Boolean values (true/false)array: Array values (stored as comma-separated strings)json: JSON valuesdate: Date valuestime: Time valuesdatetime: Date and time valuesurl: URL valuesemail: Email valuesemails: Multiple email values (stored as comma-separated strings)password: Password values (can be encrypted)
Translations
The package comes with English and Spanish translations. You can publish the translation files to customize them:
php artisan vendor:publish --tag=filament-general-settings-translations
Testing
./vendor/bin/phpunit
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-21