ofcold / nova-configurations-field
一个 Laravel Nova 字段。
1.0.1
2018-12-26 07:10 UTC
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-09-26 22:37:07 UTC
README
动态创建资源配置项。
要求
Laravel Nova。
安装
首先使用 composer 安装 Nova 包
composer require ofcold/nova-configurations-field
发布配置文件
php artisan vendor:publish --provider="Ofcold\\Configurations\\FieldServiceProvider"
然后运行迁移
php artisan migrate
用法
在您的 .env 文件中添加配置项缓存键
OFCOLD_CONFIGURATION_KEY=config
配置不同的资源
use Ofcold\Configurations\Configurations; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make()->sortable(), Configurations::make('Configurations') ->setConfigurations([ Text::make('foo'), Text::make('bar') ], 'example') ]; }
从作用域获取配置项
use Ofcold\Configurations\Repository; Repository::scopeItems($scope)
获取单个配置
use Ofcold\Configurations\Repository; // Use scope and key // Example: example::foo Repository::get('example::foo')
获取单个配置值
use Ofcold\Configurations\Repository; // Use scope and key // Example: example::foo Repository::getValue('example::foo')