A Font Awesome icon picker for Laravel Nova.
composer require mlsolutions/nova-font-awesome-field
/**
* Get the fields displayed by the resource.
*
* @param NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request): array
{
return [
\MlSolutions\FontAwesomeField\FontAwesome::make(__('Icon'), 'icon'),
];
}In the config file you can specify the available Font Awesome styles and set default parameters for the field.
php artisan vendor:publish --provider="MlSolutions\FontAwesomeField\FieldServiceProvider" --tag="config"
If the field is nullable, the function to remove the icon is also available.
FontAwesome::make('icon')->nullable()To bypass the config settings use these methods.
FontAwesome::make('icon')->showStyleSelector()FontAwesome::make('icon')->hideStyleSelector()This package uses the global translations, so you don't have to maintain them multiple times.
$this->texts = [
'header' => __('Edit Icon'),
'cancel' => __('Cancel'),
'update' => __('Update'),
'search' => __('Search'),
'remove' => __('Remove Icon'),
'styles' => __('Styles'),
'more' => __('Load more'),
'null' => __('No Icons Found'),
];use MlSolutions\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'))Default icons in this package: Font Awesome Free 6.4.0.
- Download the wanted Font Awesome package from the Font Awesome Website
- Copy the
metadata/icons.jsonfile to Your Laravel installation - Change the
icon-filepath to Youricons.jsonin Yourconfig/nova-font-awesome-field.phpconfig file - Optional, but recommended: Remove unnecessary elements from the
icons.jsonwithphp artisan nova-fa-field:shrink-icon-filecommand





