kenyalang/countries
最新稳定版本:v1.1.0
Composer 安装命令:
composer require kenyalang/countries
包简介
A package to get list of countries
README 文档
README
Installation
You can install the package via composer:
composer require kenyalang/countries
To publish the config file, you can use the following command:
php artisan vendor:publish --provider="\Kenyalang\Countries\CountriesServiceProvider" --tag=config
Usage
Run the migrations to create and populate the countries and states table.
php artisan migrate
By default, the countries will be inactive. To enable them update your .env.
ENABLE_ALL_COUNTRIES=true
To manually enable a country, you may query the desired country and use the activate function.
\Kenyalang\Countries\Models\Country::where('name', 'United States')->activate();
To disable a country, you may query the desired country and use the deactivate function.
\Kenyalang\Countries\Models\Country::where('name', 'United States')->deactivate();
To query only active countries, use the active scope.
\Kenyalang\Countries\Models\Country::active()->get();
Add the following trait to your model to use the countries and states table:
class User extends Model { use \Kenyalang\Countries\Traits\HasCountry; }
To get the locale of a model use the withLocale scope:
User::withLocale()->first();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
The list of countries was taken from here. Do check it out.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-13