subham/filament-dynamic-settings 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

subham/filament-dynamic-settings

最新稳定版本:v2.0.1

Composer 安装命令:

composer require subham/filament-dynamic-settings

包简介

Dynamic settings plugin for Filament

README 文档

README

A flexible Laravel package for managing dynamic settings in Filament admin panels with support for both single-tenant and multi-tenant applications.

Features

  • Flexible Tenancy: Works with both single-tenant and multi-tenant applications
  • Custom Components: Extensible system for custom field types
  • Dynamic Field Resolution: Automatic component resolution based on field types
  • Module Organization: Organize settings into logical modules
  • Multiple Layouts: Support for tabs and section layouts
  • Type Safety: Automatic type casting for different field types

Installation

composer require subham/filament-dynamic-settings
php artisan filament-dynamic-settings:install

Filament Compatibility

Version Filament Version
^2.x Filament v4
^1.x Filament v3

Ensure that you are using the correct version of this package that is compatible with your Filament installation

Setting Resource Image

Settings

Manage Setting Page Image (Tab/Section)

Manage Settings

Configuration

Single Tenant Setup

// config/filament-dynamic-settings.php
return [
    'multi_tenant' => false,
    // ... other config
];

Multi-Tenant Setup

// config/filament-dynamic-settings.php
return [
    'multi_tenant' => true,
    'tenant_model' => App\Models\Tenant::class,
    'tenant_column' => 'tenant_id',
    'tenant_relation => 'tenant"
    // ... other config
];

Usage

Basic Usage

use Subham\FilamentDynamicSettings\Facades\Settings;

// Get a setting
$value = Setting::get('app_name', 'general', 'Default App Name');

// Set a setting
Setting::set('app_name', 'My Application', 'general');

// In multi-tenant mode (tenant ID is auto-detected)
$value = Setting::get('app_name', 'general', 'Default App Name');

// Explicitly specify tenant
$value = Setting::get('app_name', 'general', 'Default App Name', $tenantId);

Blade Directives for Filament Dynamic Settings

@setting('key_name','module_name','default_value','tenant');
@rawsetting('key_name','module_name','default_value','tenant');
<!-- Display site title with escaping -->
<h1>@setting('site_title', 'general', 'My Website')</h1>

<!-- Display HTML content without escaping -->
<div class="footer">
    @rawsetting('footer_html', 'content', '<p>Default footer</p>')
</div>

<!-- Multi-tenant usage -->
<meta name="description" content="@setting('meta_description', 'seo', 'Default description', 'tenant_id')">

Use @setting for user-generated content. Only use @rawsetting when you need to output trusted HTML content.

Creating Custom Components

1. Register in Config

// config/filament-dynamic-settings.php
'custom_components' => [
    'color_picker' => [
        'component' => YourCustomComponent::class,
        'label' => 'Label for your component',
        'description' => 'Description..',
    ],
],

Advanced Multi-Tenant Usage

Custom Tenant Resolution

If you need custom tenant resolution logic, you can extend the Setting model:

namespace App\Models;

use Subham\FilamentDynamicSettings\Models\Setting as BaseSetting;

class Setting extends BaseSetting
{
    protected static function getCurrentTenantId()
    {
        if (auth()->check() && auth()->user()->currentTeam) {
            return auth()->user()->currentTeam->id;
        }
        
        return parent::getCurrentTenantId();
    }
}

License

This package is open-sourced software licensed under the MIT license.

Changelog

See the changelog for details on changes made in each version.

Contributing

Contributions are welcome! Please create a pull request or open an issue if you find any bugs or have feature requests.

Support

If you find this package useful, please consider starring the repository on GitHub to show your support.

统计信息

  • 总下载量: 724
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-30