定制 dipesh79/laravel-nepal-address-seeder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dipesh79/laravel-nepal-address-seeder

Composer 安装命令:

composer require dipesh79/laravel-nepal-address-seeder

包简介

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

README 文档

README

Laravel Nepal Address Seeder Package

Laravel Nepal Address Seeder

Latest Stable Version Total Downloads License

This Laravel package allows you to add Province, District and Local Levels of Nepal.

Usage/Examples

Install Using Composer

composer require dipesh79/laravel-nepal-address-seeder

Publish Vendor File For Migration And Configuration File

php artisan vendor:publish

And publish Dipesh79\LaravelNepalAddressSeeder\NepalAddressServiceProvider

Run Migration

php artisan migrate

Config File

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',

];

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

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);
    }
}

District Model

<?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');
    }
}

Local Level Model

<?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');
    }


}

Database Seeding

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.

V 0.0.4 Update

Now you can add a flag to the command.

Import Province Only

php artisan nepal-address:seed --province

Import District Only

php artisan nepal-address:seed --district

Import Local Level Only

php artisan nepal-address:seed --local-level

Force Seed

Use this flag to force seed the data. This will not ask for any prompt.

php artisan nepal-address:seed --force

TODOS

  • Wards Count

License

MIT

Author

Support

For support, email dipeshkhanal79@gmail.com.

dipesh79/laravel-nepal-address-seeder 适用场景与选型建议

dipesh79/laravel-nepal-address-seeder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 593 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dipesh79/laravel-nepal-address-seeder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dipesh79/laravel-nepal-address-seeder 我们能提供哪些服务?
定制开发 / 二次开发

基于 dipesh79/laravel-nepal-address-seeder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-26