jobmetric/laravel-location
Composer 安装命令:
composer require jobmetric/laravel-location
包简介
This is a website location management package for Laravel that you can use in your projects.
README 文档
README
Laravel Location
Location Management for Laravel. Structured. Scalable.
Laravel Location helps you model and manage geographic data in a clean, consistent way—from Countries and Provinces to Cities, Districts, Locations, Geo Areas and Addresses. It is designed to be used as a reusable package in real-world Laravel applications where location data needs to be normalized and shared across multiple models.
Why Laravel Location?
A clean hierarchy: Country → Province → City → District
Keep your geographical data normalized and queryable with a clear relational hierarchy. This makes reporting, filtering, and validation much easier across your application.
Reusable Locations, Geo Areas and Addresses
- Locations are stored as unique records (country/province/city/district combination).
- Geo Areas can reference multiple locations (non-duplicated).
- Addresses can be attached to any model (polymorphic) and are stored with a location relation.
Service-first API + Facades
Each entity is managed through a dedicated service and convenient Facades:
Country,Province,City,DistrictLocation,GeoArea,Address
This keeps controllers thin and makes the package easy to integrate and test.
Quick Start
Install via Composer:
composer require jobmetric/laravel-location
Run migrations:
php artisan migrate
Optionally publish config/translations (if you need to override defaults):
php artisan vendor:publish --provider="JobMetric\\Location\\LocationServiceProvider"
Usage (Examples)
Store a country using the Facade:
use JobMetric\Location\Facades\Country; $response = Country::store([ 'name' => 'Iran', 'flag' => 'iran.svg', 'mobile_prefix' => 98, 'validation' => [ '/^9\\d{9}$/', ], 'address_on_letter' => "{country}, {province}, {city}\n{district}, {street}, {number}", 'status' => true, ]);
Attach address/geo areas to your models using traits:
use Illuminate\Database\Eloquent\Model; use JobMetric\Location\HasAddress; use JobMetric\Location\HasGeoArea; class User extends Model { use HasAddress; } class Shipping extends Model { use HasGeoArea; }
Documentation
Documentation for Laravel Location is available here:
The documentation includes:
- Getting Started - Installation and configuration
- Traits -
HasAddress,HasGeoArea,HasLocation - Services & Facades - Complete API reference
- Requests & Resources - Validation and API responses
- Events - Hook into lifecycle events
- Testing - How to run package tests and expected patterns
Contributing
Thank you for participating in laravel-location. A contribution guide can be found here.
License
The laravel-location is open-sourced software licensed under the MIT license. See License File for more information.
jobmetric/laravel-location 适用场景与选型建议
jobmetric/laravel-location 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 7, 最近一次更新时间为 2024 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「address」 「laravel」 「location」 「country」 「city」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jobmetric/laravel-location 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jobmetric/laravel-location 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jobmetric/laravel-location 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Redirects TYPO3 visitors automatic or with a suggestlink to another language and/or root page.
Module adding custom shipping attribute for what3words address
Simple ASCII output of array data
A modern, feature-rich Laravel package for managing addresses with geocoding, validation, caching, and spatial operations. Perfect for e-commerce, CRM systems, and any application requiring robust address management.
统计信息
- 总下载量: 53
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-13