norman-huth / nova-font-awesome-field
A Laravel Nova field.
Fund package maintenance!
Ko Fi
huth.it/coffee
Installs: 2 366
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: ^8.0
- laravel/nova: ^4.0
This package is auto-updated.
Last update: 2024-12-06 20:42:26 UTC
README
A Font Awesome icon picker for Laravel Nova.
Demo: https://nova-demo.huth.it/resources/norman-huth-font-awesome-fields
Install
composer require norman-huth/nova-font-awesome-field
Usage
Add the 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'), ]; }
Optional: Publish Config
In the config file you can specify the available Font Awesome styles and set default parameters for the field.
php artisan vendor:publish --provider="NormanHuth\FontAwesomeField\FieldServiceProvider" --tag="config"
„Remove Icon“ Option
If the field is nullable
, the function to remove the icon is also available.
FontAwesome::make('icon')->nullable()
Style Selector
To bypass the config settings use these methods.
Show Style Selector
FontAwesome::make('icon')->showStyleSelector()
Hide Style Selector
FontAwesome::make('icon')->hideStyleSelector()
Translations
This package uses the global translations, so you don't have to maintain them multiple times.
Default Texts
$this->texts = [ 'header' => __('Edit Icon'), 'cancel' => __('Cancel'), 'update' => __('Update'), 'search' => __('Search'), 'remove' => __('Remove Icon'), 'styles' => __('Styles'), 'more' => __('Load more'), 'null' => __('No Icons Found'), ];
Change A Text
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'))
Icon Set
Default icons in this package: Font Awesome Free 6.4.0.
Use Other Version Or Font Awesome Pro
- Download the wanted Font Awesome package from the Font Awesome Website
- Copy the
metadata/icons.json
file to Your Laravel installation - Change the
icon-file
path to Youricons.json
in Yourconfig/nova-font-awesome-field.php
config file - Optional, but recommended: Remove unnecessary elements from the
icons.json
withphp artisan nova-fa-field:shrink-icon-file
command