需要先安裝 laravel nova
https://nova.laravel.com
composer require ofcold/nova-configurations-field
php artisan vendor:publish --provider="Ofcold\\Configurations\\FieldServiceProvider"
需要做資料遷移
php artisan migrate
快取key值,可以不用的哈!!!
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')
問題或建議歡迎大家Issues
本作品採用《CC 協議》,轉載必須註明作者和本文連結