brnysn/laravel-world
Composer 安装命令:
composer require brnysn/laravel-world
包简介
The simplest way to add country, state and city to Laravel application.
README 文档
README
The simplest way to add country, state and city to Laravel application.
Data is taken from dr5hn/countries-states-cities-database. Thanks to dr5hn for the great work.
Data is last updated on 2022-10-26.
Installation
Install the package via composer:
composer require brnysn/laravel-world
Publish the config file with:
php artisan vendor:publish --tag="world-config"
Define whether to use uuid or id in the config file: Migrations will be created according to this setting.
return [ 'use_uuid' => false, ];
Publish and run the migrations with:
php artisan vendor:publish --tag="world-migrations"
php artisan migrate
After the migration has been published you can add the countries, states and cities to your database by running:
php artisan db:seed --class="Brnysn\\World\\Database\\Seeders\\WorldSeeder"
Seeding the database will take a while.
Add HasWorldAddress trait to your models to add the country, state and city relationship:
use Brnysn\World\Traits\HasWorldAddress; class {class_name} extends Model { use HasWorldAddress; }
Usage
// Get Data use Brnysn\World\Models\Country; use Brnysn\World\Models\State; use Brnysn\World\Models\City; $country = Country::find(1); $state = State::find(1); $city = City::find(1); // Get Relationship $country->states; $state->cities; $city->state; $city->country; // Query $country->states()->where('name', 'like', '%state%')->get(); $state->cities()->where('name', 'like', '%city%')->get(); // Set Address of a model with HasWorldAddress trait $model->changeCountry($country); $model->changeState($state); $model->changeCity($city); $model->changeAddress($country, $state, $city); // Get details of address of a model with HasWorldAddress trait $model->country->name; $model->state->name;
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
brnysn/laravel-world 适用场景与选型建议
brnysn/laravel-world 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.98k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「states」 「countries」 「cities」 「laravel-address」 「brnysn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brnysn/laravel-world 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brnysn/laravel-world 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brnysn/laravel-world 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
PHP extension with Brazilian states and formats for CPF, CNPJ and ZIP
Laravel 5.2 package that provides basic geographical data like Countries, Regions and Cities.
A simple PHP class for United States Postal Service (USPS) addresses
Convert and operate with FIPS codes for states, counties, etc.
PHP Countries and Currencies
统计信息
- 总下载量: 2.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-18