norman-huth/nova-font-awesome-field

一个 Laravel Nova 字段。

1.0.0 2023-04-11 14:40 UTC

This package is auto-updated.

Last update: 2024-09-06 20:01:58 UTC


README

Font AwesomeLaravel Nova 提供图标选择器。

演示: https://nova-demo.huth.it/resources/norman-huth-font-awesome-fields

Preview with Style Selector

Preview without Style Selector

Edit Preview

Edit Preview (nullable)

Detail Preview

Index Preview

安装

composer require norman-huth/nova-font-awesome-field

使用方法

添加字段。

    /**
     * Get the fields displayed by the resource.
     *
     * @param NovaRequest $request
     * @return array
     */
    public function fields(NovaRequest $request): array
    {
        return [
            \NormanHuth\FontAwesomeField\FontAwesome::make(__('Icon'), 'icon'),
        ];
    }

可选:发布配置

配置文件 中,您可以指定可用的 Font Awesome 样式并设置字段的默认参数。

php artisan vendor:publish --provider="NormanHuth\FontAwesomeField\FieldServiceProvider" --tag="config"

“移除图标”选项

如果字段是 可空的,则也可以使用移除图标的函数。

FontAwesome::make('icon')->nullable()

样式选择器

要绕过配置设置,请使用这些方法。

显示样式选择器

FontAwesome::make('icon')->showStyleSelector()

隐藏样式选择器

FontAwesome::make('icon')->hideStyleSelector()

翻译

此包使用全局翻译,因此您不需要多次维护它们。

默认文本

$this->texts = [
    'header'   => __('Edit Icon'),
    'cancel'   => __('Cancel'),
    'update'   => __('Update'),
    'search'   => __('Search'),
    'remove'   => __('Remove Icon'),
    'styles'   => __('Styles'),
    'more'     => __('Load more'),
    'null'     => __('No Icons Found'),
];
更改文本
use NormanHuth\FontAwesomeField\FontAwesome;

FontAwesome::make('icon')->setText('header', __('Edit Icon'))
FontAwesome::make('icon')->setText('cancel', __('Cancel'))
FontAwesome::make('icon')->setText('update', __('Update'))
FontAwesome::make('icon')->setText('search', __('Search'))
FontAwesome::make('icon')->setText('remove', __('Remove Icon'))
FontAwesome::make('icon')->setText('Styles', __('Styles'))
FontAwesome::make('icon')->setText('more', __('Load more'))
FontAwesome::make('icon')->setText('null', __('No Icons Found'))

图标集

本包中的默认图标:Font Awesome Free 6.4.0。

使用其他版本或 Font Awesome Pro

  • Font Awesome 网站 下载所需的 Font Awesome 包
  • metadata/icons.json 文件复制到您的 Laravel 安装目录
  • icon-file 路径更改为您的 config/nova-font-awesome-field.php 配置文件中的 icons.json
  • 可选,但推荐:使用 php artisan nova-fa-field:shrink-icon-file 命令从 icons.json 中删除不必要的元素