smskin/nova-dadata-suggestion

一个 Laravel Nova 地址建议字段

0.0.3 2022-04-30 15:19 UTC

This package is auto-updated.

Last update: 2024-09-29 05:42:48 UTC


README

0.0.3

base library fomvasss/laravel-data 的作者 (https://github.com/fomvasss/laravel-dadata) 已删除。我找到了它的分支并更改了 composer 依赖。现在库依赖于 inkover/laravel-data。

Laravel Nova 的地址建议字段

基于 https://github.com/fomvasss/laravel-dadata

安装

  • composer require smskin/nova-dadata-suggestion
  • php artisan vendor:publish --provider="SMSkin\DaDataSuggestion\FieldServiceProvider"
  • 将变量 DADATA_TOKEN 和 DADATA_SECRET 添加到 .env 文件并填充

使用

  • 创建完整的地址字段
  • 将其链接到其他字段
  • 使用建议来填充相关字段
 private function addressFields()
    {
        return [
            DaDataSuggestion::make('DaData','address')
                ->city('address_city')
                ->flat('address_flat')
                ->street('address_street')
                ->house('address_house')
                ->geoLat('coordinate_lat')
                ->geoLon('coordinate_lon'),

            Text::make('Город', 'address_city')
                ->hideFromIndex(),
            Text::make('Улица', 'address_street')
                ->hideFromIndex(),
            Text::make('Дом', 'address_house')
                ->hideFromIndex(),
            Text::make('Офис', 'address_flat')
                ->hideFromIndex(),
            Text::make('Широта', 'coordinate_lat')
                ->hideFromIndex(),
            Text::make('Долгота', 'coordinate_lon')
                ->hideFromIndex()
        ];
    }

可用字段

  • postalCode
  • country
  • federalDistrict
  • regionType
  • regionTypeFull
  • region
  • areaType
  • areaTypeFull
  • area
  • cityWithType
  • cityType
  • cityTypeFull
  • city
  • cityDistrictWithType
  • cityDistrictType
  • cityDistrictTypeFull
  • cityDistrict
  • settlementWithType
  • settlementType
  • settlementTypeFull
  • settlement
  • streetWithType
  • streetType
  • streetTypeFull
  • street
  • houseType
  • houseTypeFull
  • houseWithType
  • house
  • blockType
  • blockTypeFull
  • block
  • flatType
  • flatTypeFull
  • flat
  • flatWithType
  • geoLat
  • geoLon