nalzai35 / filament-settings
这是我的包 filament-settings
v1.0.1
2024-07-20 07:41 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
This package is auto-updated.
Last update: 2024-09-20 08:00:31 UTC
README
此包在您的数据库中存储的filament中添加一个设置页面。
安装
您可以通过composer安装此包
composer require nalzai35/filament-settings
将插件添加到您想要的Filament面板
use Nalzai35\FilamentSettings\FilamentSettingsPlugin; class FilamentPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... ->plugins([ FilamentSettingsPlugin::make() ]); } }
您可以使用以下命令发布和运行迁移
php artisan vendor:publish --tag="filament-settings-migrations"
php artisan migrate
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="filament-settings-config"
这是发布配置文件的内容
return [ 'database_table_name' => 'settings', 'cache_key' => 'settings' ];
可选地,您可以使用以下命令发布视图
php artisan vendor:publish --tag="filament-settings-views"
用法
在app/Filament/Pages/Settings/Settings.php
创建一个设置页面
namespace App\Filament\Pages\Settings; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Nalzai35\FilamentSettings\Pages\SettingsPage; class Settings extends SettingsPage { protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth'; public function form(Form $form): Form { return $form ->schema([ Forms\Components\Tabs::make('settings') ->schema([ Forms\Components\Tabs\Tab::make('General') ->statePath('general') ->schema([ Forms\Components\TextInput::make('brand_name') ->required() ]), Forms\Components\Tabs\Tab::make('Seo Meta') ->statePath('seo_meta') ->schema([ Forms\Components\Section::make('Home Page') ->statePath('home_page') ->collapsible() ->schema([ Forms\Components\TextInput::make('title'), Forms\Components\Textarea::make('description') ]) ]) ]), ]) ->columns(1); } }
获取设置
您可以使用辅助函数setting()
获取设置,就像Laravel中的config()
函数一样
setting('general.name'); // Retrieve a default value if the configuration value does not exist... setting('general.name', 'Filament Settings'); // To set configuration values at runtime setting(['general.timezone' => 'America/Chicago']);
测试
composer test
更新日志
有关最近更改的更多信息,请参阅更新日志。
安全漏洞
请查看我们的安全策略,了解如何报告安全漏洞我们的安全策略。
致谢
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。