enflow/laravel-address
Composer 安装命令:
composer require enflow/laravel-address
包简介
Address autocomplete with support for multiple drivers
README 文档
README
The enflow/laravel-address package provides a opinionated way on how to implement address fields with autocomplete.
Usage
Step 1 - Install the package
You can install the package via composer:
composer require enflow/laravel-address
Step 2 - Config
You must publish the config to set the driver you which to use.
Pushing the config file:
php artisan vendor:publish --provider="Enflow\Address\AddressServiceProvider" --tag="config"
You must specify your driver choice. We provide a driver for HERE out of the box. See the 'Driver' section how to obtain a API key.
Step 3 - Migration
Pushing the migration file:
php artisan vendor:publish --provider="Enflow\Address\AddressServiceProvider" --tag="migrations"
Step 4 - Prepare your model
The Address model is provided free to use, and you are able to configure it just like a normal Eloquent relationship:
Migration
Schema::table('companies', function (Blueprint $table) { // ... $table->foreignId('address_id')->constrained(); });
Model
<?php use Enflow\Address\Models\Address; use Illuminate\Database\Eloquent\Model; class Company extends Model { public function address() { return $this->belongsTo(Address::class); } }
Step 5 - Frontend
We highly recommend the use of our @enflow/laravel-address-ui frontend package. This package adds the ability to add a autocomplete option to your address input for the end-user to easily select their address.
For installation instructions, see https://github.com/enflow-nl/laravel-address-ui
Step 6 - Persisting
After the form has been submitted, we wish to connect the address info the the model. This can be done with the Address::persist method. You may use it like:
$model->address()->associate(Address::persist($request->get('address')));
Drivers
We support the following drivers out of the box. This may be extended in the future, and we welcome PRs for new drivers.
HERE
HERE Geocoding and Search provides a fast and easy to use autosuggestion option. We recomend this option due it's relative low cost and ease of use, without additional legal terms.
Product page: https://developer.here.com/products/geocoding-and-search
Pricing: https://developer.here.com/pricing
You may obtain a API token by registrating for an account.
Google Places
Google Places isn't support out of the box and is something we want to support in the future. PRs are welcome!
Mapbox
Mapbox isn't support out of the box and is something we want to support in the future. PRs are welcome!
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email michel@enflow.nl instead of using the issue tracker.
Credits
About Enflow
Enflow is a digital creative agency based in Alphen aan den Rijn, Netherlands. We specialize in developing web applications, mobile applications and websites. You can find more info on our website.
License
The MIT License (MIT). Please see License File for more information.
enflow/laravel-address 适用场景与选型建议
enflow/laravel-address 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.3k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 enflow/laravel-address 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 enflow/laravel-address 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-07