Laravel Nepal Address Seeder - Get Migration And Seeder For Nepal's Province, Districts And Local Levels.
dipesh79/laravel-nepal-address-seeder is a Laravel package for laravel nepal address seeder - get migration and seeder for nepal's province, districts and local levels..
It currently has 1 GitHub stars and 597 downloads on Packagist (latest version 1.0.1).
Install it with composer require dipesh79/laravel-nepal-address-seeder.
Discover more Laravel packages by dipesh79
or browse all Laravel packages to compare alternatives.
Last updated

This Laravel package allows you to add Province, District and Local Levels of Nepal.
composer require dipesh79/laravel-nepal-address-seeder
php artisan vendor:publish
And publish Dipesh79\LaravelNepalAddressSeeder\NepalAddressServiceProvider
php artisan migrate
Set the configuration in the nepal_address_seeder.php file in the config directory.
<?php
return [
/**
* Province Model.
*
* This is the model that will be used to seed the provinces.
*/
'province' => '\Dipesh79\LaravelNepalAddressSeeder\src\Models\Province',
/**
* Province Name in the database.
*
* This is the column name in the database where the province name will be stored.
*/
'province_name' => 'name',
/**
* Opt in if you want to add capital in the database.
*
* This will add the capital of the province in the database.
*/
'add_province_capital' => false,
/**
* Province Capital in the database.
*
* This is the column name in the database where the province capital will be stored.
*/
'province_capital' => 'capital',
/**
* Opt in if you want to add no of districts in the database.
*
* This will add the no of districts in the province in the database.
*/
'add_province_no_of_districts' => false,
/**
* Province No Of District in the database.
*
* This is the column name in the database where the province no of districts will be stored.
*/
'province_no_of_districts' => 'no_of_districts',
/**
* District Model.
*
* This is the model that will be used to seed the districts.
*/
'district' => '\Dipesh79\LaravelNepalAddressSeeder\src\Models\District',
/**
* District Name in the database.
*
* This is the column name in the database where the district name will be stored.
*/
'district_name' => 'name',
/**
* Local Level Model.
*
* This is the model that will be used to seed the local levels.
*/
'local_level' => '\Dipesh79\LaravelNepalAddressSeeder\src\Models\LocalLevel',
/**
* Local Level Name in the database.
*
* This is the column name in the database where the local level name will be stored.
*/
'local_level_name' => 'name',
/**
* Opt in if you want to add wards in the database.
*
* This will add the wards in the local level in the database.
*/
'add_local_level_wards' => false,
/**
* Local Level Wards in the database.
*
* This is the column name in the database where the local level wards will be stored.
*/
'local_level_wards' => 'wards',
];
You can use your own model, or you can model from our package.
NOTE: If you are using our model, make sure you have soft delete column in your migration. If you are using our published migration, then we already have it.
<?php
namespace Dipesh79\LaravelNepalAddressSeeder\Models;
use bootstrap\LaravelNepalAddressSeeder\src\Models\District;use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Province extends Model
{
use SoftDeletes;
public $timestamps = true;
protected $guarded = [];
protected $table = 'provinces';
public function districts(): HasMany
{
return $this->hasMany(District::class);
}
}
<?php
namespace Dipesh79\LaravelNepalAddressSeeder\Models;
use bootstrap\LaravelNepalAddressSeeder\src\Models\LocalLevel;use bootstrap\LaravelNepalAddressSeeder\src\Models\Province;use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class District extends Model
{
use SoftDeletes;
public $timestamps = true;
protected $guarded = [];
protected $table = 'districts';
public function localLevels(): HasMany
{
return $this->hasMany(LocalLevel::class);
}
public function province(): BelongsTo
{
return $this->belongsTo(Province::class, 'province_id');
}
}
<?php
namespace Dipesh79\LaravelNepalAddressSeeder\Models;
use bootstrap\LaravelNepalAddressSeeder\src\Models\District;use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class LocalLevel extends Model
{
use SoftDeletes;
public $timestamps = true;
protected $guarded = [];
protected $table = 'local_levels';
public function district(): BelongsTo
{
return $this->belongsTo(District::class, 'district_id');
}
}
You can seed the database using the following command. Before seeding, make sure you have the correct model in your configuration file.
php artisan nepal-address:seed
Now you can use the data in your database.
Now you can add a flag to the command.
php artisan nepal-address:seed --province
php artisan nepal-address:seed --district
php artisan nepal-address:seed --local-level
Use this flag to force seed the data. This will not ask for any prompt.
php artisan nepal-address:seed --force
For support, email [email protected].