Skip to content

Commit

Permalink
Merge test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kpscyber committed Aug 15, 2024
2 parents 54e2ccb + 32103fc commit 3015ff3
Show file tree
Hide file tree
Showing 36 changed files with 137 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.5
uses: dependabot/fetch-metadata@v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2
uses: actions/dependency-review-action@v4
4 changes: 2 additions & 2 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

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

Expand All @@ -18,6 +18,6 @@ jobs:
args: --config=.php_cs.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
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 All @@ -20,7 +20,7 @@ jobs:
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
26 changes: 12 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'docs/**'
pull_request:
paths-ignore:
g - "**.md"
- "**.md"
- 'docs/**'
branches: [main]
jobs:
Expand All @@ -19,24 +19,22 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [7.3, 8.0, 8.1]
laravel: [8.*, 9.*]
stability: [prefer-lowest, prefer-stable]
php: [8.2]
laravel: [10.*, 11.*]
stability: [prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
packagetools: 1.13.5
- laravel: 8.*
testbench: 6.*
packagetools: 1.13.5
exclude:
- php: "8.1"
stability: "prefer-lowest"
- laravel: 10.*
testbench: 8.*
packagetools: 1.16.*
- laravel: 11.*
testbench: 9.*
packagetools: 1.16.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

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

Expand All @@ -21,7 +21,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
# Thai addressable mdoels and provinces database for Laravel.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/soap/thai-addresses.svg?style=flat-square)](https://packagist.org/packages/soap/thai-addresses)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/soap/thai-addresses/run-tests?label=tests)](https://github.com/soap/thai-addresses/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/soap/thai-addresses/Check%20&%20fix%20styling?label=code%20style)](https://github.com/soap/thai-addresses/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[![run-tests](https://github.com/soap/thai-addresses/actions/workflows/run-tests.yml/badge.svg)](https://github.com/soap/thai-addresses/actions/workflows/run-tests.yml)
[![Check & fix styling](https://github.com/soap/thai-addresses/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/soap/thai-addresses/actions/workflows/php-cs-fixer.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/soap/thai-addresses.svg?style=flat-square)](https://packagist.org/packages/soap/thai-addresses)

This package provides basic thailand provinces database including districts and subdistricts. Addresable models also provided to use with any Eloquent models.
This package provides basic thailand provinces database including districts and subdistricts. Addressable models also provided to use with any Eloquent models.
## Version Support

## Support us

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://mycoding.academy/about-us). We publish all received postcards on [our virtual postcard wall](https://mycoding.academy/open-source/postcards).

## Requirements
soap/thai-addresses v2.x for Laravel 9 and PHP 8.0 or 8.1. If you use Laravel 8, please see [release 1.x](https://github.com/soap/thai-addresses/tree/1.x) then.

## Installation

You can install the package via composer:
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
}
],
"require": {
"php": "^8.0",
"spatie/laravel-package-tools": "^1.9.2",
"illuminate/contracts": "^9.0",
"illuminate/support": "^9.0"
"php": "^8.1|^8.2",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"laravel/pint": "^1.17",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"nunomaduro/collision": "^6.0",
"nunomaduro/larastan": "^2.0.1",
"nunomaduro/collision": "^6.0|^7.0",
"larastan/larastan": "^2.0.1",
"orangehill/iseed": "^3.0",
"orchestra/testbench": "^7.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpstan/extension-installer": "^1.1",
Expand Down
32 changes: 16 additions & 16 deletions config/thai-addresses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

return [
// model definition
"geography" => [
"table_name" => "thai_geographies",
"foreign_key" => "geography_id"
'geography' => [
'table_name' => 'thai_geographies',
'foreign_key' => 'geography_id',
],

"province" => [
"table_name" => "thai_provinces",
"foreign_key" => "province_id"
'province' => [
'table_name' => 'thai_provinces',
'foreign_key' => 'province_id',
],
"district" => [
"table_name" => "thai_districts",
"foreign_key" => "district_id"

'district' => [
'table_name' => 'thai_districts',
'foreign_key' => 'district_id',
],

"subdistrict" => [
"table_name" => "thai_subdistricts",
'subdistrict' => [
'table_name' => 'thai_subdistricts',
],

"address" => [
"table_name" => "addresses",
"model" => \Soap\ThaiAddresses\Models\Address::class
]
'address' => [
'table_name' => 'addresses',
'model' => \Soap\ThaiAddresses\Models\Address::class,
],
];
3 changes: 1 addition & 2 deletions database/factories/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Soap\ThaiAddresses\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Soap\ThaiAddresses\Facades\ThaiAddresses;
use Soap\ThaiAddresses\Models\Address;

class AddressFactory extends Factory
Expand All @@ -13,7 +12,7 @@ class AddressFactory extends Factory
public function definition()
{
return [

];
}
}
7 changes: 3 additions & 4 deletions database/migrations/create_addresses_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up()
$table->string('family_name');

$table->string('label')->nullable();

$table->string('organization')->nullable();
$table->string('street')->nullable();
$table->foreignId('subdistrict_id')->nullable();
Expand All @@ -31,12 +31,11 @@ public function up()
$table->boolean('is_shipping')->default(false);
$table->timestamps();
$table->softDeletes();
});
});
}

public function down()
{
Schema::dropIfExists(ThaiAddresses::getAddressTableName());
}

};
};
3 changes: 1 addition & 2 deletions database/migrations/create_thai_districts_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
return new class extends Migration
{
public function up()
{
{
Schema::create(ThaiAddresses::getDistrictTableName(), function (Blueprint $table) {
$table->id();

Expand All @@ -26,5 +26,4 @@ public function down()
{
Schema::dropIfExists(ThaiAddresses::getDistrictTableName());
}

};
3 changes: 1 addition & 2 deletions database/migrations/create_thai_geographies_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function up()
$table->id();

// add fields

$table->string('name_en');
$table->string('name_th');
$table->timestamps();
Expand All @@ -24,5 +24,4 @@ public function down()
{
Schema::dropIfExists(ThaiAddresses::getGeographyTableName());
}

};
5 changes: 2 additions & 3 deletions database/migrations/create_thai_provinces_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public function up()
{
Schema::create(ThaiAddresses::getProvinceTableName(), function (Blueprint $table) {

$table->id();
// add fields
$table->string('code');
Expand All @@ -23,7 +23,6 @@ public function up()

public function down()
{
Schema::dropIfExists(ThaiAddresses::getProvinceTableName(),);
Schema::dropIfExists(ThaiAddresses::getProvinceTableName());
}

};
5 changes: 2 additions & 3 deletions database/migrations/create_thai_subdistricts_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
return new class extends Migration
{
public function up()
{
{
Schema::create(ThaiAddresses::getSubdistrictTableName(), function (Blueprint $table) {
$table->id();

Expand All @@ -26,5 +26,4 @@ public function down()
{
Schema::dropIfExists(ThaiAddresses::getSubdistrictTableName());
}

};
};
12 changes: 5 additions & 7 deletions database/seeders/DistrictSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

namespace Soap\ThaiAddresses\Database\Seeders;

use File;
use Illuminate\Database\Seeder;
use Soap\ThaiAddresses\Models\District;
use File;


class DistrictSeeder extends Seeder
{

public function run()
{
District::query()->delete();
$json = File::get(base_path('vendor/soap/thai-addresses/database/seeders/data/districts.json'));
$districts = json_decode($json);

foreach($districts as $item) {
foreach ($districts as $item) {
District::create([
'id' => $item->id,
'code' => $item->code,
'name_th' => $item->name_th,
'name_en' => $item->name_en,
config('thai-addresses.province.foreign_key') => $item->province_id
config('thai-addresses.province.foreign_key') => $item->province_id,
]);
}
}

}
}
12 changes: 5 additions & 7 deletions database/seeders/GeographySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@

namespace Soap\ThaiAddresses\Database\Seeders;

use File;
use Illuminate\Database\Seeder;
use Soap\ThaiAddresses\Models\Geography;
use File;


class GeographySeeder extends Seeder
{

public function run()
{
Geography::query()->delete();
$json = File::get(base_path('vendor/soap/thai-addresses/database/seeders/data/geographies.json'));
$geographies = json_decode($json);

foreach($geographies as $item) {
foreach ($geographies as $item) {
Geography::create([
'id' => $item->id,
'name_th' => $item->name_th,
'name_en' => $item->name_en
'name_en' => $item->name_en,
]);
}
}

}
}
Loading

0 comments on commit 3015ff3

Please sign in to comment.