zmap95/vietnam-maps is a Laravel package for vietnam's area database..
It currently has 0 GitHub stars and 7 downloads on Packagist (latest version v1.0.4).
Install it with composer require zmap95/vietnam-maps.
Discover more Laravel packages by zmap95
or browse all Laravel packages to compare alternatives.
Last updated
Database of Vietnam's area.
Data are taken directly from the General Statistics Office of Vietnam.
composer require zmap95/vietnam-maps
Extract directly via command:
php artisan vietnam-map:install
php artisan vendor:publish --provider="Zmap95\VietnamMap\VietnamMapServiceProvider"
Open file config/vietnam-maps.php and config:
'tables' => [
'provinces' => 'provinces',
'districts' => 'districts',
'wards' => 'wards',
],
Open file config/vietnam-maps.php and config:
'columns' => [
'name' => 'name',
'gso_id' => 'gso_id',
'province_id' => 'province_id',
'district_id' => 'district_id',
],
Open the following migration files and customize if you need:
database/migrations/{datetime}_create_vietnam_maps_table.php
php artisan migrate
php artisan vietnam-map:download
use Zmap95\VietnamMap\Models\Province;
use Zmap95\VietnamMap\Models\District;
use Zmap95\VietnamMap\Models\Ward;
class DevController extends Controller
{
...
public function dev()
{
$provinces = Province::all();
$districts = District::all();
$wards = Ward::all();
...
}
}
use zmap95\VietnamMap\Models\Province;
class DevController extends Controller
{
...
public function dev()
{
$province = Province::first();
$districts = $province->districts;
...
}
}
class Province extends Model
{
...
public function districts()
{
return $this->hasMany(District::class);
}
}
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);
}
}
class Ward extends Model
{
...
public function district()
{
return $this->belongsTo(District::class, config('vietnam-maps.columns.district_id'), 'id');
}
}
Please see CHANGELOG for more information what has changed recently.
The Laravel framework is open-sourced software licensed under the MIT license.