rajibbinalam/country-state-city

查找全球各国、州和城市

v0.2.0 2023-04-07 14:16 UTC

README

Latest Version on Packagist Total Downloads

此包为您提供关于国家、州和城市名称及其一些本地信息的全球信息

安装

您可以通过composer安装此包

composer require rajibbinalam/country-state-city

发布供应商文件:找到以下文件

  • config > CountryStateCity.php
  • database > migrations > country, state, city 和 timezone
  • database > seeders > country, state, city 和 timezone
php artisan vendor:publish 
# Provider: rajib\LaravelCountryStateCity\CountryStateCityServiceProvider

配置迁移表名称和字段

return [
    
	/*
	|--------------------------------------------------------------------
	| Configaration Your Migrations.
    |----------------------------------------------------------------
    | Set the table_name or use default LIKE: 'table_name' => 'countries',
    |----------------------------------------------------------------
    | 'required' => true, will be added to the migration as a field
	|---------------------------------------------------------------------
	*/
	'migrations' => [
		'countries' => [
			'table_name' => 'countries',
			'optional_fields' => [
				'phone_code' => [
					'required' => true,
					'length' => 5,
				],
				'iso3' => [
					'required' => false,
					'length' => 3,
				],
			],
		],
	],
];

迁移

php artisan migrate

数据库播种

将播种器文件注册到您的 DatabaseSeeder.php 并运行播种命令

$this->call([
    CountryTableSeeder::class,
    StateTableSeeder::class,
    CityTableSeeder::class,
    TimezoneTableSeeder::class,
]);
php artisan db:seed    # it's need some time to seed the database

贡献

我们将尊重您的贡献。请参阅CONTRIBUTING以获取详细信息。

鸣谢

许可

MIT许可(MIT)。请参阅许可文件以获取更多信息。