polygon/laravel-countries

Laravel Countries 是一个用于 Laravel 的包,为所有国家提供几乎完整的 ISO 3166_2、3166_3、货币、首都等信息。

安装: 741

依赖: 0

建议者: 0

安全性: 0

类型:laravel-library

1.4.3 2015-06-10 09:52 UTC

This package is auto-updated.

Last update: 2021-09-21 13:26:38 UTC


README

Total Downloads Latest Stable Version Latest Unstable Version

Laravel Countries 是一个用于 Laravel 的包,为所有国家提供几乎完整的 ISO 3166_2、3166_3、货币、首都等信息。

请注意,2.0 版本仅适用于 Laravel 5

安装

在项目文件夹中打开您的终端,并运行: polygon/laravel-countriescomposer.json

composer require polygon/laravel-countries=2.0.x-dev

运行 composer update 以获取最新的国家列表版本。

编辑 app/config/app.php 并添加 providerfilter

'providers' => [
    'Polygon\Countries\CountriesServiceProvider',
]

现在添加别名。

'aliases' => [
    'Countries' => 'Polygon\Countries\CountriesFacade',
]

模型

您可以从发布配置开始。这是一个可选步骤,它包含表名且不需要更改。如果默认名称 countries 适合您,请保留它。否则,运行以下命令

$ php artisan vendor:publish

接下来生成迁移文件

$ php artisan countries:migration

它将生成 <timestamp>_setup_countries_table.php 迁移文件和 CountriesSeeder.php 种子文件。为了确保数据被种植,请在 seeds/DatabaseSeeder.php 中插入以下代码

//Seed the countries
$this->call('CountriesSeeder');
$this->command->info('Seeded the countries!'); 

现在您可以运行它,使用 artisan migrate 命令

$ php artisan migrate --seed

运行此命令后,填充的国家表将可用