Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dipesh79/laravel-nepal-address-seeder

Laravel Nepal Address Seeder - Get Migration And Seeder For Nepal's Province, Districts And Local Levels
https://github.com/dipesh79/laravel-nepal-address-seeder

Last synced: 2 days ago
JSON representation

Laravel Nepal Address Seeder - Get Migration And Seeder For Nepal's Province, Districts And Local Levels

Awesome Lists containing this project

README

        

![Laravel Nepal Address Seeder Package](https://banners.beyondco.de/laravel-nepal-address-seeder.png?theme=light&packageManager=composer+require&packageName=dipesh79%2Flaravel-nepal-address-seeder&pattern=architect&style=style_1&description=Laravel+Nepal+Address+Seeder+-+Get+Migration+And+Seeder+For+Nepal%27s+Province%2C+Districts+And+Local+Levels&md=1&showWatermark=1&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg)
# Laravel Nepal Address Seeder

[![Latest Stable Version](http://poser.pugx.org/dipesh79/laravel-nepal-address-seeder/v)](https://packagist.org/packages/dipesh79/laravel-user-logs)
[![Total Downloads](http://poser.pugx.org/dipesh79/laravel-nepal-address-seeder/downloads)](https://packagist.org/packages/dipesh79/laravel-user-logs)
[![License](http://poser.pugx.org/dipesh79/laravel-nepal-address-seeder/license)](https://packagist.org/packages/dipesh79/laravel-user-logs)

This Laravel package allows you to add Province, District and Local Levels of Nepal.
## Usage/Examples
### Install Using Composer
```bash
composer require dipesh79/laravel-nepal-address-seeder
```
### Publish Vendor File For Migration And Configuration File
```bash
php artisan vendor:publish
```
And publish `Dipesh79\LaravelNepalAddressSeeder\NepalAddressServiceProvider`
### Run Migration
```bash
php artisan migrate
```
## Config File

Set the configuration in the `nepal_address_seeder.php` file in the config directory.

```php
'\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',

];

```
## Model
You can use your own model, or you can model from our package.

### Province Model
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
hasMany(District::class);
}
}
```
### District Model

```php
hasMany(LocalLevel::class);
}

public function province(): BelongsTo
{
return $this->belongsTo(Province::class, 'province_id');
}
}
```

### Local Level Model

```php
belongsTo(District::class, 'district_id');
}

}

```

## Database Seeding

You can seed the database using the following command. Before seeding, make sure you have the correct model in your configuration file.

```bash
php artisan nepal-address:seed
```
Now you can use the data in your database.
## V 0.0.4 Update
Now you can add a flag to the command.

### Import Province Only

```bash
php artisan nepal-address:seed --province
```
### Import District Only
```bash
php artisan nepal-address:seed --district
```
### Import Local Level Only
```bash
php artisan nepal-address:seed --local-level
```
### TODOS

* Wards Count

## License

[MIT](https://choosealicense.com/licenses/mit/)

## Author

- [@Dipesh79](https://www.github.com/Dipesh79)

## Support

For support, email [email protected].