netcore/module-country

此包最新版本(v1.1.3)没有提供许可证信息。

Netcore CMS生态系统中的国家模块

v1.1.3 2018-06-07 10:11 UTC

This package is not auto-updated.

Last update: 2024-09-23 07:39:26 UTC


README

本模块提供用于操作国家列表和货币列表的帮助方法。

安装前

此包是Netcore CMS生态系统的一部分,并且仅在安装了以下包的项目中才能正常工作

  1. https://github.com/netcore/netcore

安装

  • 使用composer安装此包
composer require netcore/module-country
  • 发布配置、迁移和资源
php artisan module:publish-config Country
php artisan module:publish-migration Country
php artisan module:publish Country
php artisan migrate
  • 将配置种子到数据库
php artisan module:seed Country

用法

  • 获取所有国家
country()->all();
  • 通过其ISO 3166-2代码查找国家
$country = country()->findByCode('SE');
$country->code; // SE
$country->name; // Sweden
$country->capital; // Stockholm
$country->full_name; // Kingdom of Sweden
$country->calling_code; // 46
$country->eea; // true
$country->flag_url; // Will return asset URL to the country flag
  • 获取所有国家作为选择列表的集合(将返回此格式的集合 - ID => 国家名称)
country()->getSelectList();

您还可以将国家或货币附加到任何模型

public function country(): Illuminate\Database\Eloquent\Relations\BelongsTo
{
    return $this->belongsTo(Modules\Country\Models\Country::class);
}
public function currency(): Illuminate\Database\Eloquent\Relations\BelongsTo
{
    return $this->belongsTo(Modules\Country\Models\Currency::class);
}

免责声明

我们不对源文件中提供的国家、货币和国旗列表的准确性承担责任。列表的创建不考虑任何政治和宗教观点。如果您发现国家列表不准确,请随意复制存储库并按您的意愿更改列表。

待办事项

  • 添加单元测试
  • 在管理面板中使国家和货币可管理