marshmallow / dataset-google-geotargets
将所有来自Google的GeoTargets导入您的Laravel项目中。
v1.2.0
2022-07-20 14:15 UTC
Requires
- php: ^7.4|^8.0
- marshmallow/dataset-country: ^1.2
- marshmallow/sluggable: ^1.0
This package is auto-updated.
Last update: 2024-08-30 01:09:14 UTC
README
Laravel Google 地理位置目标
此数据集包含来自Google的所有地理位置。当Google发布新版本时,我们会更新源代码,您可以重新生成数据。默认情况下仅导入荷兰的数据,但您可以在配置中更改此设置。
安装
composer require marshmallow/dataset-google-geotargets
迁移
在运行迁移之前,请先发布迁移文件。
php artisan vendor:publish --provider="Marshmallow\Datasets\GoogleGeoTargets\ServiceProvider" --tag="migrations" ``` Run `php artisan migrate` to create the database schema's. # Publish the config Publish the config so you are able to choose which countries will be seeded to the table and which data types will be seeded. By default this is set to The Nederlands and data types. If you want this to be seeded, you don't need to publish the config. ```bash php artisan vendor:publish --provider="Marshmallow\Datasets\GoogleGeoTargets\ServiceProvider"
return [ /** * Specify the countries you wish to sync. An empty array will * result in the seeder seeding all the data. */ 'countries' => [ 'NL', ], /** * Specify the types you wish to sync. */ 'types' => [ GoogleGeoTarget::CITY, // ... ] ];
填充表
我们需要填充两个表,国家表和Google地理目标表。
# Seed the country table. php artisan db:seed --class="Marshmallow\Datasets\Country\Seeders\CountrySeeder" # Seed the Google Geo Target table php artisan db:seed --class="Marshmallow\Datasets\GoogleGeoTargets\Seeds\GoogleGeoTargetsSeeder"
用法
$country = Country::alpha2('NL'); $country->provinces->first()->cities->first()->name;
版权所有 (c) 2020 marshmallow