mohammadhprp/filament-ip-to-country-flag-column

Display Country flag from IP address in your Filament tables

Maintainers

Package info

github.com/mohammadhprp/filament-ip-to-country-flag-column

Language:Blade

pkg:composer/mohammadhprp/filament-ip-to-country-flag-column

Transparency log

Statistics

Installs: 19 523

Dependents: 0

Suggesters: 0

Stars: 22

Open Issues: 0

v2.1.0 2026-08-17 17:05 UTC

README

License Latest Version on Packagist Total Downloads Plumb score

Display country flag from IP address in your Filament tables

This version supports Filament 5 and requires PHP 8.2 or newer.

Warning This plugin may cause a slight delay in page loading due to API calls to iplocation.

Screenshot

image

Installation

You can install the package via composer:

composer require mohammadhprp/filament-ip-to-country-flag-column

Usage

To use the package, follow these steps:

use Mohammadhprp\IPToCountryFlagColumn\Columns\IPToCountryFlagColumn;

IPToCountryFlagColumn::make('client_ip');

Options

  1. Flag position: Change the position of the flag using flagPosition. Available options: right and left.

    IPToCountryFlagColumn::make('client_ip')->flagPosition('left');

    💡 Note: Default flag position is right.

  2. Hide flag: Hide the flag using hideFlag.

    IPToCountryFlagColumn::make('client_ip')->hideFlag();
  3. Location position: Change the location position using location(). Available options: below and above.

    IPToCountryFlagColumn::make('client_ip')->location(position: 'above');

    💡 Note: Default location position is below.

  4. Location separator: Change the location separator using location().

    IPToCountryFlagColumn::make('client_ip')->location(separator: '-');

    💡 Note: Default location separator is ,.

  5. Hide city or country name: Hide city or country name using hideCity() or hideCountry().

    IPToCountryFlagColumn::make('client_ip')
         ->hideCountry()
         ->hideCity();
  6. Custom location resolver: Use a custom resolver to cache lookups or use another IP location provider.

    IPToCountryFlagColumn::make('client_ip')
        ->locationResolver(fn (string $ip): array => [
            'country_code' => 'US',
            'country_name' => 'United States',
            'city' => 'Mountain View',
        ]);
  7. Lazy loading: Defer location lookups until the table has loaded. This avoids blocking the initial page response when the column is used with a deferred Filament table.

    protected function table(Table $table): Table
    {
        return $table
            ->deferLoading()
            ->columns([
                IPToCountryFlagColumn::make('client_ip')->lazy(),
            ]);
    }

    Location responses from the default provider are cached for 24 hours. Use locationResolver() when you need application-specific caching or a different provider.

Testing

composer test

Example Application

The example/ directory contains a Laravel 12 and Filament 5 application using this package through a local Composer path repository. See example/README.md for setup and login instructions.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature.
  3. Make your changes and commit them with clear commit messages.
  4. Submit a pull request to the master branch.

Credits

License

This project is licensed under the MIT License - see the License file for details.