Vietnam administrative unit database for Laravel

Tram Ho

Hello everyone, today I would like to share with you the database of administrative units of Vietnam: Province / City, District / District, Ward / Commune for Laravel

This is the first time I have written an article here, it may not be very good, hope you guys understand

Introduce

The day before, I was working on a project to get data about the Vietnamese administrative unit, so I repackaged it as a package for Laravel and shared it with everyone.

Link it here: https://github.com/kjmtrue/vietnam-zone

What this package has:

  • Data is extracted directly from the General Statistics Office, so you are assured of accuracy and the data is always updated.
  • Quick installation.
  • Supports Laravel 5.8 and above.

Setting

Installation through composer:

Copy the config file and migrate

If you do not need to customize your database, you can skip this step and through the Data Import section

Database customization

If you want to customize the structure of the database table for your project, do the following:

Rename the table

Open config/vietnam-zone.php file and change the tables section:

Rename the column

Open the config/vietnam-zone.php file and change the columns section:

Where gso_id not a random or incremental ID, it is an official boundary code issued under the Government’s Decision No. 124/2004 / QD-TTg of July 8, 2004. This column will be used as a reference for future data updates.

province_id and district_id are foreign key columns.

More Collum

Open the following migration files and customize them to your liking:

Import data

Run the migrate command to make the table creation.

Finally download and import the data with the following command:

summary

Above is my share, if you have any questions or requests for me to add to the library, please let me know in the comments below. Those who come over see it, please give me a copy to get the motivation to update.

Thank you for taking the time to support your article!

Share the news now

Source : Viblo