andreasgj / nova-settings-tool

Nova 的应用程序设置管理工具。

v1.0.5 2020-07-26 10:53 UTC

This package is auto-updated.

Last update: 2024-09-26 20:40:15 UTC


README

Latest Version on Packagist Total Downloads Build StyleCI License: MIT

在 Nova 中存储和编辑简单的全局设置。设置以 JSON 格式存储,使用 spatie/valuestore,使它们非常容易 在其他地方使用

Settings Tool screenshot

安装

通过 Composer 在任何 Laravel 应用中使用 Nova 安装此包

composer require andreasgj/nova-settings-tool

将默认配置文件发布到 config/nova-settings-tool.php

php artisan vendor:publish --tag="nova-settings-tool"

在您的 NovaServiceProvidertools 方法中注册该工具

// in app/Providers/NovaServiceProvider.php

use Andreasgj\NovaSettingsTool\SettingsTool;

    // ...

    public function tools()
    {
        return [
            new SettingsTool,
        ];
    }

使用方法

设置在 nova-settings-tool.php 配置文件中声明。此文件指定设置存储的位置、在 Nova 侧边栏中工具的标题、设置页面的布局以及有关设置本身的元数据。

包括一个 默认配置文件,其中包含一些有用的示例 作为起点

panels 数组中的每个条目都是一个包含 Nova 字段的选项卡。选项卡也可以显示为侧边栏,因此如果您有很多设置,则不需要滚动查看全部。

Settings Tool in accordion mode screenshot

设置的实际值以 JSON 格式存储在配置文件中指定的位置——默认为 storage/app/settings.json

您可以使用所有 Nova 字段,除了关系字段 以外

  • 徽章 - 似乎需要一个与资源的关联。
  • 布尔分组 - 似乎需要一个与资源的关联。
  • Gravatar - 需要与资源关联。
  • ID - 需要与资源关联。

此包中的所有字符串以及您传递给它的任何字符串都可以使用 Laravel 内置的本地化功能 轻松翻译。

获取存储的配置?

我们现在已经添加了一种简单的方法来获取您需要的配置。以下是一些您可以使用的全局函数

/**
 * This function will return key value of the configs specified in the $keys array.
 */
function get_store_configs(array $keys = []): Object

/**
 * This function will return the value of the config specified in the $key string.
 */
function get_store_config(string $key): mix

/**
 * This function will return Laravel\Nova\Fields\Field of the config specified in the $attribute string.
 */
function get_store_config_field(string $attribute): Laravel\Nova\Fields\Field

/**
 * This function will return a collection of all the fields setup in the config file.
 */
function get_store_config_fields(): collect

/**
 * This function will return a collection of all the panels setup in the config file.
 */
function get_store_config_panels(): collect

路线图

以下功能正在计划或开发中

  • ?

变更日志贡献许可证