norman-huth / nova-font-awesome-field
一个 Laravel Nova 字段。
1.0.0
2023-04-11 14:40 UTC
Requires
- php: ^8.0
- laravel/nova: ^4.0
This package is auto-updated.
Last update: 2024-09-06 20:01:58 UTC
README
为 Font Awesome 的 Laravel Nova 提供图标选择器。
演示: https://nova-demo.huth.it/resources/norman-huth-font-awesome-fields
安装
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中删除不必要的元素





