pepperfm / filament-json
处理 JSON 字段的 Filament 插件
1.1.6
2024-07-17 14:49 UTC
Requires
- php: ^8.2
- filament/filament: ^3.0
- illuminate/support: ^10.45|^11.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- pestphp/pest-plugin-livewire: ^2.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
安装
您可以通过 composer 安装此包
composer require pepperfm/filament-json
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="filament-json-config"
可选,您可以使用以下命令发布视图
php artisan vendor:publish --tag="filament-json-views"
用法
use PepperFM\FilamentJson\Columns\JsonColumn; JsonColumn::make('properties'); JsonColumn::make('properties') ->asDrawer(); JsonColumn::make('properties') ->asModal();
自定义按钮和模态属性
use PepperFM\FilamentJson\Columns\JsonColumn; $buttonConfig = [ 'color' => 'warning', 'size' => 'xs', ]; $modalConfig = literal( icon: 'heroicon-m-sparkles', alignment: 'start', width: 'xl', closedButton: false, ); JsonColumn::make('properties') ->asModal() ->button($buttonConfig) ->modal($modalConfig);
代码 button()
和 modal()
方法接受类型为 array|Arrayable|\stdClass
,并实现了 Filament 文档中 Blade 组件的基本属性:核心概念 - Blade 组件
以下是实现组件配置的 DTO 类
class ButtonConfigDto { public string $color = 'primary'; public string $icon = 'heroicon-o-swatch'; public ?string $label = null; public ?string $tooltip = null; public string $size = 'md'; public ?string $href = null; public ?string $tag = null; } class ModalConfigDto { public ?string $id = null; public string $icon = 'heroicon-o-swatch'; public string $iconColor = 'primary'; public string $alignment = 'start'; public string $width = 'xl'; public bool $closeByClickingAway = true; public bool $closedByEscaping = true; public bool $closedButton = true; public bool $autofocus = true; }
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全漏洞
请审查 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。