3neef/laravel-nationalities
最新稳定版本:v1.0.2
Composer 安装命令:
composer require 3neef/laravel-nationalities
包简介
A Laravel package that provides localized nationality names with support for exclusions
README 文档
README
A Laravel package that provides localized nationality names with support for exclusions. Compatible with Laravel, Laravel Filament, and other Laravel-based applications.
Features
- 🌍 Localized nationality names using Laravel's translation system
- 🚫 Optional exclusion of specific nationality codes
- 🎯 Laravel Filament compatible
- 📦 Easy installation via Composer
- 🔧 Automatic service provider registration
- 🌐 Supports multiple locales (English, Arabic, and more)
Installation
Install the package via Composer:
composer require 3neef/laravel-nationalities
The service provider will be automatically registered thanks to Laravel's package auto-discovery.
Usage
Basic Usage
use Aneef\Nationalities\Nationalities; // Get all nationalities $all = Nationalities::get(); // Get nationalities excluding specific codes $filtered = Nationalities::get(['US', 'EG']);
Example Output
When app()->getLocale() === 'en':
[
'EG' => 'Egyptian',
'SA' => 'Saudi',
'US' => 'American',
'GB' => 'British',
// ... more nationalities
]
When app()->getLocale() === 'ar':
[
'EG' => 'مصري',
'SA' => 'سعودي',
'US' => 'أمريكي',
'GB' => 'بريطاني',
// ... more nationalities
]
Laravel Filament Usage
Perfect for Filament forms and tables:
use Filament\Forms\Components\Select; use Aneef\Nationalities\Nationalities; Select::make('nationality') ->options(Nationalities::get()) ->searchable() ->required()
Blade Templates
<select name="nationality"> @foreach(Nationalities::get() as $code => $name) <option value="{{ $code }}">{{ $name }}</option> @endforeach </select>
Publishing Translations
To customize the nationality translations, publish the language files:
php artisan vendor:publish --provider="Aneef\Nationalities\NationalitiesServiceProvider" --tag="lang"
This will publish the translation files to resources/lang/vendor/nationalities/.
Supported Languages
- English (
en) - Arabic (
ar)
You can add more languages by creating additional translation files.
Requirements
- PHP ^8.1
- Laravel ^9.0|^10.0|^11.0
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-07