uatthaphon/laravel-thai-address

包含经纬度的泰国省级数据库。

0.1.3 2018-02-05 05:48 UTC

This package is auto-updated.

Last update: 2024-09-12 13:49:39 UTC


README

包含经纬度的泰国省级数据库。

设置

将包依赖添加到您的项目中

composer require uatthaphon/laravel-thai-address

在 Laravel 5.5 之前,将包的服务提供者添加到您的项目配置文件 config/app.php

'providers' => [
  ...

  Uatthaphon\ThaiAddress\ThaiAddressServiceProvider::class,
],

运行发布以发布 3 个标签 => migrations csv seeds

php artisan vendor:publish

发布完成后,您可以通过运行迁移来创建表

php artisan migrate

然后运行种子,它将抓取 csv 文件并将它们填充到每个表中

php artisan db:seed --class=ThailandAddressSeeder

用法

您可以使用可用的模型为泰国地址表使用

use Uatthaphon\ThaiAddress\Models\ThailandProvince;
use Uatthaphon\ThaiAddress\Models\ThailandDistrict;
use Uatthaphon\ThaiAddress\Models\ThailandSubdistrict;

...

/**
 * Available Relationships
 */

// list all districts under the province
app(ThailandProvince::class)->find(1)->districts()->get();

// get province of the district
app(ThailandDistrict::class)->find(1)->province;
// list all sub districtes under the district
app(ThailandDistrict::class)->find(1)->subdistricts()->get();

// get district of the subdistrict
app(ThailandSubdistrict::class)->find(1)->district;
// get province of the subdistrict
app(ThailandSubdistrict::class)->find(1)->province;

致谢

如果没有 aaronamm/thai-administrative-division-province-district-subdistrict-sql 提供的出色的数据库源,这个项目将不会存在。