reworck / filament-settings
此包最新版本(0.4.0)没有可用的许可证信息。
管理spatie/valuestore的filament设置
0.4.0
2023-04-21 08:55 UTC
Requires
- php: ^8.0
- livewire/livewire: ^v2.8.2
- spatie/valuestore: ^1.2
README
此包允许使用Spatie的ValueStore包轻松管理设置。
配置文件内容
return [ // Group the menu item belongs to 'group' => 'Settings', // Sidebar label 'label' => 'Settings', // Path to the file to be used as storage 'path' => storage_path('app/settings.json'), ];
安装
- 需要此包
composer require reworck/filament-settings
- 发布配置文件
php artisan vendor:publish --tag=filament-settings-config
- (可选)你可以发布页面的视图以及由livewire组件使用的视图
php artisan vendor:publish --tag=filament-settings-views
用法
通过在您的AppServiceProvider
的boot
方法中添加以下内容来定义您的字段
\Reworck\FilamentSettings\FilamentSettings::setFormFields([ \Filament\Forms\Components\TextInput::make('title'), ]);
之后,您可以使用spatie/valuestore像平常一样访问您的值
隐藏页面给用户
要隐藏设置页面的一部分用户,请向您的User
模型添加一个canManageSettings
方法。
public function canManageSettings(): bool { return $this->can('manage.settings'); }
默认情况下,页面将显示给所有用户。
测试
composer test
安全
如果您发现任何安全相关的问题,请通过电子邮件quinten@reworck.nl联系,而不是使用问题跟踪器。
致谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。