Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/LaravelWilayahDatabaseSeeder.php
#	src/Models/District.php
  • Loading branch information
hanzo-asashi committed Oct 5, 2023
2 parents d591228 + 0ac0db8 commit 87e5990
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand Down
22 changes: 12 additions & 10 deletions database/migrations/2023_10_05_030904_create_wilayah_table.php
@@ -1,59 +1,61 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class extends Migration
{
public function up(): void
{
Schema::create(config('wilayah.table_prefix') . 'cities', static function (Blueprint $table) {
Schema::create(config('wilayah.table_prefix').'cities', static function (Blueprint $table) {
$table->char('city_code', 4)->primary();
$table->char('province_code', 2);
$table->string('name', 255);
$table->foreign('province_code')
->references('province_code')
->on(config('wilayah.table_prefix') . 'provinces')
->on(config('wilayah.table_prefix').'provinces')
->onUpdate('cascade')
->onDelete('restrict');
});

Schema::create(config('wilayah.table_prefix') . 'districts', static function (Blueprint $table) {
Schema::create(config('wilayah.table_prefix').'districts', static function (Blueprint $table) {
$table->char('district_code', 7)->primary();
$table->char('city_code', 4);
$table->string('name', 255);
$table->foreign('city_code')
->references('city_code')
->on(config('wilayah.table_prefix') . 'cities')
->on(config('wilayah.table_prefix').'cities')
->onUpdate('cascade')
->onDelete('restrict');
});

Schema::create(config('wilayah.table_prefix') . 'villages', static function (Blueprint $table) {
Schema::create(config('wilayah.table_prefix').'villages', static function (Blueprint $table) {
$table->char('village_code', 10)->primary();
$table->char('district_code', 7);
$table->string('name', 255);
$table->foreign('district_code')
->references('district_code')
->on(config('wilayah.table_prefix') . 'districts')
->on(config('wilayah.table_prefix').'districts')
->onUpdate('cascade')
->onDelete('restrict');
});

Schema::create(config('wilayah.table_prefix') . 'islands', static function (Blueprint $table) {
Schema::create(config('wilayah.table_prefix').'islands', static function (Blueprint $table) {
$table->char('island_code', 5)->primary();
$table->char('province_code', 2);
$table->char('city_code', 4);
$table->string('name', 255);
$table->foreign('province_code')
->references('province_code')
->on(config('wilayah.table_prefix') . 'provinces')
->on(config('wilayah.table_prefix').'provinces')
->onUpdate('cascade')
->onDelete('restrict');
$table->foreign('city_code')
->references('city_code')
->on(config('wilayah.table_prefix') . 'cities')
->on(config('wilayah.table_prefix').'cities')
->onUpdate('cascade')
->onDelete('restrict');
});
Expand Down
1 change: 0 additions & 1 deletion src/LaravelWilayahServiceProvider.php
Expand Up @@ -2,7 +2,6 @@

namespace HanzoAlpha\LaravelWilayah;

use HanzoAlpha\LaravelWilayah\Commands\LaravelWilayahCommand;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand Down
5 changes: 4 additions & 1 deletion src/Models/Island.php
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace HanzoAlpha\LaravelWilayah\Models;
Expand All @@ -15,13 +16,15 @@ class Island extends Model
use HasRelationships;

protected $primaryKey = 'island_code';

public $timestamps = false;

protected $fillable = ['island_code', 'province_code', 'city_code', 'name'];

public function __construct(array $attributes = [])
{
if (empty($this->table)) {
$this->setTable(config('wilayah.table_prefix') . 'islands');
$this->setTable(config('wilayah.table_prefix').'islands');
}

parent::__construct($attributes);
Expand Down
3 changes: 2 additions & 1 deletion src/Models/Province.php
Expand Up @@ -15,14 +15,15 @@ class Province extends Model
use HasRelationships;

protected $primaryKey = 'province_code';

public $timestamps = false;

protected $fillable = ['province_code', 'name'];

public function __construct(array $attributes = [])
{
if (empty($this->table)) {
$this->setTable(config('wilayah.table_prefix') . 'provinces');
$this->setTable(config('wilayah.table_prefix').'provinces');
}

parent::__construct($attributes);
Expand Down
3 changes: 2 additions & 1 deletion src/Models/Village.php
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace HanzoAlpha\LaravelWilayah\Models;
Expand All @@ -22,7 +23,7 @@ class Village extends Model
public function __construct(array $attributes = [])
{
if (empty($this->table)) {
$this->setTable(config('wilayah.table_prefix') . 'villages');
$this->setTable(config('wilayah.table_prefix').'villages');
}

parent::__construct($attributes);
Expand Down

0 comments on commit 87e5990

Please sign in to comment.