定制 claytongf/laravel-world-seed 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

claytongf/laravel-world-seed

最新稳定版本:v1.1.2

Composer 安装命令:

composer require claytongf/laravel-world-seed

包简介

A Laravel package that contains information about countries, states, cities, airports, currencies, languages and timezones

README 文档

README

This Laravel package provides data about countries, states, cities, currencies, languages, airports, translations, and timezones.

Installation

Install Using Composer

composer require claytongf/laravel-world-seed

Laravel

Publish the configuration file:

php artisan vendor:publish --provider="Claytongf\\WorldSeed\\Providers\\WorldSeedServiceProvider"

Migrations

After publishing, you can run the migrations and the tables will be created.

php artisan migrate

Configurations

The config/world.php file (published in the previous step) allows customization of table names, relationship table names, relationship column names, countries to seed, progress bar display, and a list of countries being processed.

[!NOTE] > Model selection for seeding is not yet customizable and will be available in future releases. Setting 'countries' or other models to true or false will not affect seeding.

Available Commands

World Seed

Seed the entire database.

Important

Run Migrations first!

php artisan world:add-country

Warning

Seeding the entire dataset can take a while.

Tip

For faster seeding, use the command below or specify country codes in the config/world.php file.

Seed Specific Country

Add specific countries using their ISO2 or ISO3 codes:

php artisan world:add-country US # or USA
php artisan world:add-country USA MEX CAN # Multiple countries
php artisan world:add-country BR MEX FR ESP # Mixed ISO2 and ISO3 codes

Duplicate entries will be ignored.

Remove Specific Country

Remove countries using their ISO2 or ISO3 codes:

php artisan world:remove-country CAN # or CA
php artisan world:remove-country CAN BRA MEX # Multiple countries
php artisan world:remove-country CA BR MX # Mixed ISO2 and ISO3 codes

Attempts to remove already removed countries will be ignored. For example, if you try to remove MX, CA, and BR, but MX has already been removed, the command will proceed to remove CA and BR.

Seed Airports

Seed all the airports available.

Important

Seed countries first, otherwise no airports will be shown.

php artisan world:add-airport

Warning

Seeding all airports can take a while, though less time than seeding countries.

Tip

For faster seeding, use the command below or specify airport codes in the config/world.php file.

Seed Specific Airport

Add specific airports using their IATA or ICAO codes:

php artisan world:add-airport YYZ # or CYYZ
php artisan world:add-airport YYZ YYN ORL # Multiple airports
php artisan world:add-airport CYYZ ORL CGH # Mixed IATA and ICAO codes

Duplicate entries will be ignored.

Remove Specific Airports

Remove airports using their IATA or ICAO codes:

php artisan world:remove-airport YYZ # or CYYZ
php artisan world:remove-airport YYZ YYN ORL # Multiple airports
php artisan world:add-airport CYYZ CYYN CGH # Mixed IATA and ICAO codes

If an airport is already removed, it will not affect the other airports removal. Per example: if you want to remove the airports with YYZ, YYN and ORL codes, but ORL has already been removed before, the command will ignore the removed airport and continue to remove the other ones.

Retrieving Data

Data retrieval currently follows standard Laravel conventions. Improved methods will be implemented in future versions.

Models Available

  • Country
  • State
  • City
  • Currency
  • Language
  • Timezone
  • Translation
  • Airport

Relationships

  • City
    • BelongsTo State
    • BelongsTo Country
    • BelongsToMany Airport
  • State
    • BelongsTo Country
  • Country
    • BelongsToMany Currency
    • BelongsToMany Language
    • BelongsToMany Timezone
    • HasMany Translation
  • Currency
    • BelongsToMany Country
  • Language
    • BelongsToMany Country
  • Timezone
    • BelongsToMany Country
  • Translation
    • BelongsTo Country
  • Airport
    • BelongsToMany City

Suggestions are welcome!

Package in development

This package is currently in its initial version. All suggestions are welcome.

Data Integrity

Important

The dataset may contain inconsistencies, such as airports not linked to any city. Due to the volume of data, addressing all such issues may be time-consuming. Please report any inconsistencies you encounter.

Future Implementations

  • Seeding Countries, States, or Cities individually
  • Optional seeding of Languages, Timezones, Currencies, and Translations
  • Improved data retrieval methods

Buy me a Coffee..... or Pizza

Buy me a Coffee or Pizza

统计信息

  • 总下载量: 190
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-31