ichtrojan/laravel-location
Composer 安装命令:
composer require ichtrojan/laravel-location
包简介
README 文档
README
Introduction 🖖
This Package offers a simple way to get Countries, Cities and States that you may need for your Application, most especially for dropdown menus.
Step One - Install via Composer 🎼
Require the package via composer into your project
composer require ichtrojan/laravel-location
Step Two - Publish Configurations ⚙️
Laravel location provides you with an easy way of customizing the tables used for storing Countries, States and Cities. Also, you can customisethe route prefix and middleware. To customize these you need to publish the configuration file. To publish the configuration file, run:
php artisan vendor:publish --tag=laravel-location
You will have config/location.php available for you to edit. The default configurations are:
<?php return [ 'countries_table' => 'countries', 'cities_table' => 'cities', 'states_table' => 'states', 'routes' => [ 'prefix' => 'location', 'middleware' => 'web' ] ];
You can go ahead and customize the table names, route prefix and middleware as you need before running the Migration.
Step Three - Running Migrations
before you do this make sure your correct Database credentials are set in the
.envfile
php artisan migrate
Finally, run the Package seeders
php artisan db:seed --class=Ichtrojan\\Location\\Seeds\\LocationDatabaseSeeder
Usage 🧨
NOTE
The routes below are prefixed withlocationwhich is the default configuration set in theconfig/location.phpfile. If mofified, replace the prefixin your route with the correct prefix.
| Route | Description |
|---|---|
/location/countries |
return all countries |
/location/country/{id} |
return a single country by its ID |
/location/states |
return all states |
/location/state/{id} |
return a single state by its ID |
/location/states/{countryID} |
return all states in a country using the country ID |
/location/cities |
return all cities |
/location/city/{id} |
return a single city by its ID |
/location/cities/{stateID} |
return all cities in a state using the state ID |
Test
composer test
Contribution
Free for all, if you find an issue with the package or if a group of people somehow created a new country please send in a PR.
Danke Schön
ichtrojan/laravel-location 适用场景与选型建议
ichtrojan/laravel-location 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.92k 次下载、GitHub Stars 达 210, 最近一次更新时间为 2019 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ichtrojan/laravel-location 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ichtrojan/laravel-location 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 210
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-11