soap/thai-addresses
Composer 安装命令:
composer require soap/thai-addresses
包简介
Thai provinces database for Laravel application
README 文档
README
This package provides basic thailand provinces database including districts and subdistricts. Addressable models also provided to use with any Eloquent models.
Version Support
| Laravel | Version |
|---|---|
| 8.x | 1.x |
| 9.x | 2.x |
| 10.x, 11.x, 12.x | 3.x |
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
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 then.
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
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
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
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Soap\ThaiAddresses\Tests\Database\Factories\UserFactory; use Soap\ThaiAddresses\Traits\HasAddress; class User extends Authenticatable { use HasFactory; use HasAddress; protected $guarded = []; protected $fillable = [ 'name', 'email', ]; }
Then your user can have addresses!
// Get instance of your model $user = new \App\Models\User::find(1); // Create a new address $user->addresses()->create([ 'label' => 'Default Address', 'given_name' => 'Prasit', 'family_name' => 'Gebsaap', 'organization' => 'KPS Academy', 'street' => '1/8 Watchara road', 'subdistrict_id' => Subdistrict::where('name_th','=','กระบี่ใหญ่')->first()->id, 'latitude' => '31.2467601', 'longitude' => '29.9020376', 'is_primary' => true, 'is_billing' => true, 'is_shipping' => true, ]); // Create multiple new addresses $user->addresses()->createMany([ [...], [...], [...], ]); // Find an existing address $address = app('thai-addresses.address.model')->find(1); // Update an existing address $address->update([ 'label' => 'Default Work Address', ]); // Delete address $address->delete(); // Alternative way of address deletion $user->addresses()->where('id', 123)->first()->delete();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
soap/thai-addresses 适用场景与选型建议
soap/thai-addresses 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 440 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「soap」 「laravel」 「addresses」 「provinces」 「thai」 「thailand」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soap/thai-addresses 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soap/thai-addresses 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soap/thai-addresses 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
A PHP client for the Salesforce SOAP API
A library that can render international postal addresses in different formats.
Laravel Package for opinionated addresses style
Addresses Manager for Laravel Enso
Yii2 Module Addresses
统计信息
- 总下载量: 440
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-08