mohammadhprp / filament-ip-to-country-flag-column
Display Country flag from IP address in your Filament tables
Package info
github.com/mohammadhprp/filament-ip-to-country-flag-column
Language:Blade
pkg:composer/mohammadhprp/filament-ip-to-country-flag-column
Requires
- php: ^8.2
- ext-curl: *
- filament/tables: ^5.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
This package is auto-updated.
Last update: 2026-08-17 17:05:43 UTC
README
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
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
-
Flag position: Change the position of the flag using
flagPosition. Available options:rightandleft.IPToCountryFlagColumn::make('client_ip')->flagPosition('left');
💡 Note: Default flag position is
right. -
Hide flag: Hide the flag using
hideFlag.IPToCountryFlagColumn::make('client_ip')->hideFlag();
-
Location position: Change the location position using
location(). Available options:belowandabove.IPToCountryFlagColumn::make('client_ip')->location(position: 'above');
💡 Note: Default location position is
below. -
Location separator: Change the location separator using
location().IPToCountryFlagColumn::make('client_ip')->location(separator: '-');
💡 Note: Default location separator is
,. -
Hide city or country name: Hide city or country name using
hideCity()orhideCountry().IPToCountryFlagColumn::make('client_ip') ->hideCountry() ->hideCity();
-
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', ]);
-
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
- Fork the repository.
- Create a new branch for your feature.
- Make your changes and commit them with clear commit messages.
- Submit a pull request to the
masterbranch.
Credits
License
This project is licensed under the MIT License - see the License file for details.
