定制 hoangphi/vietnam-maps 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hoangphi/vietnam-maps

最新稳定版本:v1.3.4

Composer 安装命令:

composer require hoangphi/vietnam-maps

包简介

Vietnam's area database.

README 文档

README

Database of Vietnam's area.

Data are taken directly from the General Statistics Office of Vietnam.

Latest Version on Packagist Total Downloads

Install

composer require hoangphi/vietnam-maps

Extracting

Method 1:

Extract directly via command:

php artisan vietnam-map:install

Method 2:

Copy file config và migration

php artisan vendor:publish --provider="HoangPhi\VietnamMap\VietnamMapServiceProvider"

Customize config và migration

  1. Rename table

Open file config/vietnam-maps.php and config:

'tables' => [
    'provinces' => 'provinces',
    'districts' => 'districts',
    'wards'     => 'wards',
],
  1. Rename column

Open file config/vietnam-maps.php and config:

'columns' => [
    'name'        => 'name',
    'gso_id'      => 'gso_id',
    'province_id' => 'province_id',
    'district_id' => 'district_id',
],
  1. Add column

Open the following migration files and customize if you need:

database/migrations/{datetime}_create_vietnam_maps_table.php

Run migration

php artisan migrate

Download và import into database

php artisan vietnam-map:download

Usage with Models

  1. Get all provinces, districts, wards
    use HoangPhi\VietnamMap\Models\Province;
    use HoangPhi\VietnamMap\Models\District;
    use HoangPhi\VietnamMap\Models\Ward;

   class DevController extends Controller
   {
       ...
       public function dev()
       {
           $provinces = Province::all();
           $districts = District::all();
           $wards = Ward::all();
           ...
       }
   }
  1. Get data using relationship
    use HoangPhi\VietnamMap\Models\Province;

   class DevController extends Controller
   {
       ...
       public function dev()
       {
           $province = Province::first();
           $districts = $province->districts;
           ...
       }
   }
  1. Relation in Province.php
    class Province extends Model
    {
        ...
        public function districts()
        {
            return $this->hasMany(District::class);
        }
    }
  1. Relation in District.php
    class District extends Model
    {
        ...
        public function province()
        {
            return $this->belongsTo(Province::class, config('vietnam-maps.columns.province_id'), 'id');
        }
        
        public function wards()
        {
            return $this->hasMany(Ward::class);
        }
    }
  1. Relation in Ward.php
    class Ward extends Model
    {
        ...
        public function district()
        {
            return $this->belongsTo(District::class, config('vietnam-maps.columns.district_id'), 'id');
        }
    }

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security-related issues, please email hoangphidev@gmail.com instead of using the issue tracker.

Credits

References

  1. General Statistics Office of Vietnam
  2. Vietnam Zone

License

The Laravel framework is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固