ichbin/filament-settings

该包的最新版本(v3.0)没有可用的许可证信息。

管理 spatie/valuestore 的 filament 设置

v3.0 2023-07-30 20:20 UTC

This package is auto-updated.

Last update: 2024-09-30 01:49:01 UTC


README

img

此包允许使用 Spatie 的 ValueStore 包轻松管理设置

Spatie 的 Generate sitemaps 包

配置文件内容

安装

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'),
];

需要此包

  1. 发布配置文件
composer require ichbin/filament-settings "^v2.0"
  1. (可选)您可以发布页面视图和 livewire 组件使用的视图
php artisan vendor:publish --tag=filament-settings-config
  1. 使用
php artisan vendor:publish --tag=filament-settings-views

定义你的字段

AppServiceProviderboot 方法中添加以下内容来定义你的字段

\IchBin\FilamentSettings\FilamentSettings::setFormFields([
    \Filament\Forms\Components\TextInput::make('title'),
]);

之后,您可以使用 spatie/valuestore 如常访问您的值

或在 blade 中

{{ setting('key') }}

隐藏页面给用户

要隐藏设置页面某些用户,请向您的 User 模型添加一个 canManageSettings 方法。

public function canManageSettings(): bool
{
    return $this->can('manage.settings');
}

默认情况下,页面将显示给所有用户。