octavianparalescu/judete-orase-comune-sectoare-laravel-seeder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

octavianparalescu/judete-orase-comune-sectoare-laravel-seeder

Composer 安装命令:

composer require octavianparalescu/judete-orase-comune-sectoare-laravel-seeder

包简介

Seeder for administrative territories (UAT - 'Unități Administrativ-Teritoriale) from Romania that uses wikidata

README 文档

README

Seeder for administrative territories in Romania that uses wikidata

Installing

Use the composer cmd: composer require octavianparalescu/judete-orase-comune-sectoare-laravel-seeder:dev-master As you are probably using the seeder for development purposes, use the --dev option to save the package to require-dev: composer require octavianparalescu/judete-orase-comune-sectoare-laravel-seeder:dev-master --dev

Using

Create a seeder that extends the UatSeeder class, define the table that needs seeding and the mappings from WikiData to your table's columns:

<?php

class CountiesSeeder extends OctavianParalescu\UatSeeder\UatSeeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $table = 'counties';
        $mapping = [
            'countySirutaId' => 'id',
            'countyLabel' => 'name',
            'typesOfCountiesLabel' => 'type',
        ];
        $insertChunkSize = 200;

        $this->seed($table, $mapping, $insertChunkSize);
    }
}

You can also use the seed() method multiple times in a single seeder (for example to seed both the counties and the cities):

<?php

class CountiesSeeder extends OctavianParalescu\UatSeeder\UatSeeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $table = 'counties';
        $mapping = [
            'countySirutaId' => 'id',
            'countyLabel' => 'name',
            'typesOfCountiesLabel' => 'type',
        ];

        $this->seed($table, $mapping);

        $table = 'cities';
        $mapping = [
            'countySirutaId' => 'county_id',
            'townLabel' => 'name',
            'typesOfTownsLabel' => 'type',
            'sirutaId' => 'id',
        ];
        $insertChunkSize = 500;

        $this->seed($table, $mapping, $insertChunkSize);

        $this->seed(
            'sate',
            [
                'countySirutaId' => 'county_id',
                'sirutaId' => 'city_id',
                'sateLabel' => 'name',
                'sateCoords' => 'coords',
            ],
            500
        );

    }
}

As you can see the mappings are an array with the keys equal to flags defined by the seeder and the values being table columns defined in your migrations. The list of the flags is:

countyLabel - string
typesOfCountiesLabel - enum{diviziune administrativă de rangul întâi, județ}
countySirutaId - int
townLabel - string
typesOfTownsLabel - enum{comună, municipiu, oraș, sector al Bucureștiului}
sirutaId - int (town siruta id)
coords - string (format: Point(lat, long))
website - string
sateLabel - string
sateCoords - string (format: Point(lat, long))
sateSirutaId - int (village siruta id)

ToDo:

  • split coords to Lat/Long

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-02