Skip to content

TappNetwork/nova-select-country-code

Repository files navigation

Laravel Nova Country Code Select Field

Latest Version on Packagist Code Style Action Status - Pint Total Downloads

A country code select field for Laravel Nova.

Appearance

Form

select-country-code-form select-country-code-form1

Detail

select-country-code-detail

Installation

Install using Composer:

composer require tapp/select-country-code

Publish the flag icons assets to the public project directory:

php artisan vendor:publish --tag=public --force

Usage

Add the field to your resource in the fields method:

use Tapp\SelectCountryCode\SelectCountryCode;

SelectCountryCode::make(__('Country Code')),

Options

iconsDirectory

Default: '/vendor/tapp/nova-select-country-code'.

If you want to use your own custom image icons, provide the directory of the images with this option:

SelectCountryCode::make(__('Country Code'))
    ->iconsDirectory('/public/path/to/icons'),

iconsFormat

Default: 'svg'.

The image format of the flag icons.

SelectCountryCode::make(__('Country Code'))
    ->iconsFormat('png'),

options

Array with the options to show on select. The array must contain the associative keys: 'label', 'country_code', and 'iso_code'.

Default:

[
    ['label' => 'Afghanistan', 'country_code' => '+93', 'iso_code' => 'AF'],
    ['label' => 'Albania', 'country_code' => '+355', 'iso_code' => 'AL'],
    // ...
]
SelectCountryCode::make(__('Country Code'))
    ->options($optionsArray),

Credits

SVG of the countries' flags by:

Leveraged package