定制 customd/laravel-addressable 二次开发

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

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

customd/laravel-addressable

最新稳定版本:v7.3.0

Composer 安装命令:

composer require customd/laravel-addressable

包简介

Laravel Addressable is a Laravel package to manage addresses that belong to your models. You can add addresses to any eloquent model with ease.

README 文档

README

Custom D Addressable is a Laravel package to manage addresses that belong to your models. You can add addresses to any eloquent model with ease.

Packagist Scrutinizer Code Quality Travis StyleCI License

Installation

  1. Install the package via composer:

    composer require customd/laravel-addresses
  2. Publish resources (migrations and config files):

    php artisan vendor:publish --provider="CustomD\Addressable\AddressesServiceProvider"
  3. Run migrations:

    php artisan migrate
  4. Done!

Usage

To add addresses support to your eloquent models simply use \CustomD\Addressable\Traits\Addressable trait.

Manage your 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' => 'Jane',
    'family_name' => 'Doe',
    'organization' => 'Custom D',
    'country_code' => 'eg',
    'street' => '56 john doe st.',
    'state' => 'Canterbury',
    'city' => 'Christchurch',
    'postal_code' => '7614',
    'latitude' => '31.2467601',
    'longitude' => '29.9020376',
    'is_primary' => true,
]);

// Create multiple new addresses
$user->addresses()->createMany([
    [...],
    [...],
    [...],
]);

// Find an existing address
$address = app('addressable.address')->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();

Manage your addressable model

The API is intuitive and very straight forward, so let's give it a quick look:

// Get instance of your model
$user = new \App\Models\User::find(1);

// Get attached addresses collection
$user->addresses;

// Get attached addresses query builder
$user->addresses();

// Scope Primary Addresses
$primaryAddresses = app('addressable.address')->isPrimary()->get();

// Scope Addresses in the given country
$egyptianAddresses = app('addressable.address')->inCountry('eg')->get();

// Find all users within 5 kilometers radius from the latitude/longitude 31.2467601/29.9020376
$fiveKmAddresses = \App\Models\User::findByDistance(5, 'kilometers', '31.2467601', '29.9020376')->get();

// Alternative method to find users within certain radius
$user = new \App\Models\User();
$users = $user->lat('31.2467601')->lng('29.9020376')->within(5, 'kilometers')->get();

Changelog

Refer to the Changelog for a full history of the project.

Support

Please raise a GitHub issue.

Contributing & Protocols

Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.

Bug reports, feature requests, and pull requests are very welcome.

Security Vulnerabilities

If you discover a security vulnerability within this project, please send an e-mail to help@customd.com. All security vulnerabilities will be promptly addressed.

License

This software is released under The MIT License (MIT).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-24