承接 gp10devhts/ug-village-locations 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gp10devhts/ug-village-locations

Composer 安装命令:

composer require gp10devhts/ug-village-locations

包简介

village locations package for uganda

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A production-ready Laravel package that provides Uganda administrative locations from District → County → Sub County → Parish → Village.

Features

  • Full administrative hierarchy: Districts, Counties, Sub-Counties, Parishes, and Villages.
  • Fast seeding via SQL dumps (offline support).
  • Configurable hierarchy depth.
  • Eloquent models and relationships.
  • Name-based searching scopes.
  • Maintainer tools for data collection from remote sources.
  • Optional UUID support.

Installation

You can install the package via composer:

composer require gp10devhts/ug-village-locations

Publish the config and migrations:

php artisan vendor:publish --tag="ug-village-locations-config"
php artisan vendor:publish --tag="ug-village-locations-migrations"

Run the migrations:

php artisan migrate

Seed the locations:

php artisan ug-locations:seed

Configuration

You can customize the package via config/ug-village-locations.php:

return [
    'seed_levels' => [
        'districts',
        'counties',
        'sub_counties',
        'parishes',
        'villages',
    ],
    'use_uuids' => false,

    'models' => [
        'district' => \Gp10devhts\UgVillageLocations\Models\District::class,
        'county' => \Gp10devhts\UgVillageLocations\Models\County::class,
        'sub_county' => \Gp10devhts\UgVillageLocations\Models\SubCounty::class,
        'parish' => \Gp10devhts\UgVillageLocations\Models\Parish::class,
        'village' => \Gp10devhts\UgVillageLocations\Models\Village::class,
    ],
];

Usage

Eloquent Models

use Gp10devhts\UgVillageLocations\Models\District;
use Gp10devhts\UgVillageLocations\Models\Village;

// Get all districts
$districts = District::all();

// Search by name
$kampala = District::search('Kampala')->first();

// Relationships
$counties = $kampala->counties;
$villages = Village::where('name', 'like', '%Kibuli%')->with('parish.subCounty.county.district')->get();

// Using the Facade for model resolution and helper methods
use Gp10devhts\UgVillageLocations\Facades\UgVillageLocations;

$districtModel = UgVillageLocations::districtModel();
$districts = UgVillageLocations::districts();
$counties = UgVillageLocations::counties($districtId);

Demo Project

A demo Laravel project is available at github.com/GP10DevHTS/ug-locations-demo.

Notices:

  • the project uses a custom District model to add regions.
  • the model extention migrations use the default table names from the package.

Model Extensibility

You can override the default models by updating the models array in the config file. This allows you to add custom relationships, scopes, or traits.

// config/ug-village-locations.php
'models' => [
    'village' => App\Models\Village::class,
],

Your custom model should extend the package's base model:

namespace App\Models;

use Gp10devhts\UgVillageLocations\Models\Village as BaseVillage;

class Village extends BaseVillage
{
    // Custom logic
}

Artisan Commands

  • php artisan ug-locations:seed: Seed the database from local SQL dumps.
  • php artisan ug-locations:truncate: Wipe all administrative location data.
  • php artisan ug-locations:fetch: (Maintainer only) Fetch fresh data from remote source.
  • php artisan ug-locations:build-dump: (Maintainer only) Generate SQL dumps from fetched data.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-28