shimadotdev/iran-regions
Composer 安装命令:
composer require shimadotdev/iran-regions
包简介
A Laravel package containing province and city data of Iran, including calling codes, along with geolocation functionality. Ideal for managing location-based information within Laravel apps.
README 文档
README
Iran Regions Laravel Package
A Laravel package containing province and city data of Iran, including calling codes, along with geolocation functionality. Ideal for managing location-based information within Laravel apps.
Installation
You can install the package via Composer by running:
composer require shimadotdev/iran-regions
After installing the package, run the following Artisan command to set up the necessary migrations and seed the database with provided data:
php artisan iran-regions:install
This command will create two tables named cities and provinces in your database, seeded with the required data.
Usage
Once the package is installed and migrations are run, you can start using the provided functionality.
Example Usage
You can access province and city data using the Iran Class:
use Shimadotdev\IranRegions\Iran;; // Get a province by its slug $province = Iran::province()->where('slug', '=', 'tehran')->first(); // Get all provinces with their slugs and calling codes $provinces = Iran::province()->get(['slug', 'calling_code']); //Update a city $provinces = Iran::city()->where('slug', '=', 'qom')->update(['is_active'=> 0]); //Relations Iran::province()->with('cities')->get(); Iran::province()->find(3)->cities; Iran::City()->with('province')->get(); Iran::City()->where('slug', 'naeen')->first()?->province->slug;
As you see, you can also utilize Laravel's Eloquent ORM to create custom queries and interact with the data as usual.
Localization Support
The package supports two languages: English (en) and Persian (fa) for all city and province names. You can access them using their respective slugs:
trans('iranRegions::slug.' . $province->slug);
Database Structure
The package creates the following tables in your database:
cities Table
| Column | Description |
|---|---|
| id | Primary key |
| slug | City slug |
| is_active | Active status |
| province_id | Foreign key to provinces table |
| latitude | City latitude |
| longitude | City longitude |
provinces Table
| Column | Description |
|---|---|
| id | Primary key |
| slug | Province slug |
| is_active | Active status |
| latitude | Province latitude |
| longitude | Province longitude |
| calling_code | Calling code of the province |
Testing
You can run the automated tests for the package using PHPUnit:
phpunit
Contributing
Contributions are welcome! If you have any ideas for improvements or find any issues, please submit them through GitHub issues or create a pull request.
Security Vulnerabilities
If you discover any security vulnerabilities, please report them via email to hi@shima.dev
Credits
This package is developed and maintained by Shima.Dev
License
This package is open-source software licensed under the MIT licensev.
shimadotdev/iran-regions 适用场景与选型建议
shimadotdev/iran-regions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 17, 最近一次更新时间为 2024 年 05 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「iran」 「iran-regions」 「iran-geo-coordinates」 「iran-cities」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shimadotdev/iran-regions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shimadotdev/iran-regions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shimadotdev/iran-regions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package for connecting to all Iraninan payment gateways
Iranian payment gateways handler for laravel applicationss
Alfabank REST API integration
KaveNegar.com webservice for Laravel
Jalali (Shamsi) DateTime class written in PHP, Supports year higher than 2038
Connect to Iran payment gateways through PHP(laravel).
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-19