PHPackages                             soap/thai-addresses - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. soap/thai-addresses

ActiveLibrary[Database &amp; ORM](/categories/database)

soap/thai-addresses
===================

Thai provinces database for Laravel application

v3.2.0(8mo ago)4437[4 PRs](https://github.com/soap/thai-addresses/pulls)MITPHPPHP ^8.2|^8.3CI passing

Since Nov 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/soap/thai-addresses)[ Packagist](https://packagist.org/packages/soap/thai-addresses)[ Docs](https://github.com/soap/thai-provinces)[ RSS](/packages/soap-thai-addresses/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (15)Versions (16)Used By (0)

Thai addressable mdoels and provinces database for Laravel.
===========================================================

[](#thai-addressable-mdoels-and-provinces-database-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d48db3a23b21409eb7f92ce4a6062be997fe147872f0d6d6ebcd50d40c4b6164/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f61702f746861692d6164647265737365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/thai-addresses)[![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://camo.githubusercontent.com/340c74deab282a058a353058dd6738411548d919631a5a507487f452bf078f56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f61702f746861692d6164647265737365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soap/thai-addresses)

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

Version Support
---------------

[](#version-support)

LaravelVersion8.x1.x9.x2.x10.x, 11.x, 12.x3.xSupport us
----------

[](#support-us)

If you found benefit from using the package, you can recommend any approvements, bugs report or even support me through GitHub Sponsor.

Requirements
------------

[](#requirements)

soap/thai-addresses v3.x supports Laravel 10 and 11 on PHP8.2 and 8.3. 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
------------

[](#installation)

You can install the package via composer:

```
composer require soap/thai-addresses
```

You can publish the config file with:

```
php artisan vendor:publish --tag="thai-addresses-config"
```

This is the contents of the published config file:

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

    "province" => [
        "table_name" => "thai_provinces",
        "foreign_key" => "province_id"
    ],

    "district" => [
        "table_name" => "districts",
        "foreign_key" => "district_id"
    ],

    "subdistrict" => [
        "table_name" => "subdistricts",
    ],

    "address" => [
        "table_name" => "addresses",
         "model" => \Soap\ThaiAddresses\Models\Address::class
    ]
];
```

You can change table name for all models in the configuration file.

Then you can publish and run the migrations with:

```
php artisan vendor:publish --tag="thai-addresses-migrations"
php artisan migrate
```

Optionally, you can install configuration and migration files using install command.

```
php artisan thai-addresses:install
```

Usage
-----

[](#usage)

If you want to use only province, district and subdistrict data, you can just run database seeding.

```
php artisan thai-addresses:db-seed
```

This will install all thai addresses data to the database as configure in the thai-addresses.conf file.

### Manage your address

[](#manage-your-address)

To add addresses support to your eloquent models simply use \\Soap\\ThaiAddresses\\Traits\\HasAddress trait. This package provide polymorphic addressable model. By using this feature, any model can have addresses.

In your App\\Models\\User.php

```
