定制 stylers/laravel-address 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

stylers/laravel-address

最新稳定版本:5.0

Composer 安装命令:

composer require stylers/laravel-address

包简介

Laravel Address Manager

README 文档

README

Latest Stable Version Total Downloads License Build Status codecov Maintainability

Laravel version compatibility

Laravel version Package version
5.7 1.0
5.8 1.1
6.0 1.1
7.0 2.0
8.0 3.0
9.0 4.0
10.0 5.0

Installation

composer require stylers/laravel-address

You can publish the migration

php artisan vendor:publish --provider="Stylers\Address\Providers\AddressServiceProvider"

After the migration has been published, you can run the migrations

php artisan migrate

Usage

use Stylers\Address\Contracts\Models\Traits\HasAddressesInterface;
use Stylers\Address\Models\Traits\HasAddresses;

class User extends Authenticatable implements HasAddressesInterface
{
    use Notifiable;
    use HasAddresses;
}

Update or Create Address

If the $type is exists then will be update with $attributes.

use Stylers\Address\Enums\AddressTypeEnum;

$user = User::first();
$attributes = [
    "country" => "Hungary",
    "zip_code" => "1055",
    "city" => "Budapest",
    "name_of_public_place" => "Kossuth Lajos",
    "type_of_public_place" => "place",
    "number_of_house" => "1-3",
    "floor" => "42",
    "door" => "69",
    "latitude" => "47.5070738",
    "longitude" => "19.045599",
    "parcel_number" => "10086/0/A/3",
]; // array
$type = AddressTypeEnum::PRIMARY; // ?string
$address = $user->updateOrCreateAddress($attributes, $type); // AddressInterface

Delete Address

use Stylers\Address\Enums\AddressTypeEnum;

$user = User::first();
$type = AddressTypeEnum::PRIMARY; // ?string
$isDeleted = $user->deleteAddress($type); // boolean

Sync Address(es)

The syncAddresses() method delete all addressable address if $type is not exists in $arrayOfAttributes[$type][]. The syncAddresses() method create all $type of arrayOfAttributes[$type][] if type is not exists in addresses table.

use Stylers\Address\Enums\AddressTypeEnum;

$user = User::first();
$arrayOfAttributes = [
    AddressTypeEnum::MAILING => [
        "country" => "Hungary",
        "zip_code" => "1055",
        "city" => "Budapest",
        "name_of_public_place" => "Kossuth Lajos",
        "type_of_public_place" => "place",
        "number_of_house" => "1-3",
        "floor" => "42",
        "door" => "69",
        "latitude" => "47.5070738",
        "longitude" => "19.045599",
        "parcel_number" => "10086/0/A/3",
    ]
];
$addresses = $user->syncAddresses($arrayOfAttributes); // Collection

How to Test

$ docker run -it --rm -v $PWD:/app -w /app composer bash
$ composer install
$ ./vendor/bin/phpunit

Troubleshooting

# Fatal error: Allowed memory size of...
$ COMPOSER_MEMORY_LIMIT=-1 composer install

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固