承接 zhiephie/lushi 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zhiephie/lushi

Composer 安装命令:

composer require zhiephie/lushi

包简介

A library of static Eloquent models for data Administrative Subdivisions of Indonesia.

README 文档

README

CI status

Lushi is a library of static Eloquent models for fixture data Administrative Subdivisions of Indonesia, such as provincies, regencies, districts and villages.

Contents

Installing Lushi

You can use Composer to install Lushi into your application.

composer require zhiephie/lushi

No additional setup is required.

Using a model

You can interact with a Lushi model just like you would any other Eloquent model, except that it only handles read-only operations.

use Lushi\Models\Country;

Province::all(); // Get information about all provinces.

Province::find(11); // Get information about the ID 11.

Province::where('name', 'like', '%JAWA%')->get(); // Get information about all provinces that contain the character "JAVA".

Available models

Lushi\Models\Province

Column Name Description Example
id ID province. 11
name Province name. Jawa Timur
Relationship name Model
regencies Lushi\Models\Regency

Lushi\Models\Regency

Column Name Description Example
id ID regency. 1101
province_id ID province. 11
name Regency name. KOTA SABANG
Relationship name Model
districts Lushi\Models\District

Lushi\Models\District

Column Name Description Example
id ID District. 1101010
regency_id ID regency. 1101
name District name. TEUPAH SELATAN
Relationship name Model
villages Lushi\Models\Village

Model relationships

Implementing an Eloquent relationship between a model in your app and a Lushi model is very simple. There are a couple of approaches you could take.

Using inheritance

The simplest option is to create a new model in your app, and let it extend the Lushi model. Your new app model will now behave like the original Lushi model, except you can register new methods and customise it to your liking:

<?php

namespace App\Models;

use Lushi\Models\Province as LushiProvince;

class Province extends LushiProvince
{
    public function users()
    {
        return $this->hasMany(User::class);
    }
}

See our section on model customisation for more customisation possibilities that are made available if you utilise this method.

Column customisation

Lushi allows you to customise the column names on any provided model.

Create a new model within your app and let it extend the Lushi model that you would like to customise:

<?php

namespace App\Models;

use Lushi\Models\Province as LushiProvince;

class Province extends LushiProvince
{
    protected $map = [
        'id' => 'province_code',
    ];
}

In this example, the App\Models\Province, extending the Lushi\Models\Province model, has the province_code column remapped to id:

use App\Models\Province;

Province::find(11)->province_code;

Contributing

If you have fixture data to contribute to the library, please open a pull request!

For reference, check out the existing models.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固