aquinoaldair/phone-code

国家电话编码或标记

1.4 2020-04-23 19:46 UTC

This package is auto-updated.

Last update: 2024-09-24 05:40:28 UTC


README

Latest Version on Packagist Build Status Total Downloads

Laravel 5.8 或更高版本,6.x,7.x

安装

您可以通过composer安装此包

composer require aquinoaldair/phone-code

使用方法

属性

nombre, name, phone_code, iso2, iso3

use Aquinoaldair\PhoneCode\PhoneCode;


//PRINCIPAL FUNCTIONS


$phonecode = new PhoneCode();

$phonecode->make("2281694545")->fromName('Mexico'); // return "522281694545"
$phonecode->makeFull("2281694545")->fromName('Mexico'); // return "+522281694545"

$phonecode->make("2281694545")->fromIso2('MX'); // return "522281694545"
$phonecode->makeFull("2281694545")->fromIso2('MX'); // return "+522281694545" 

$phonecode->make("2281694545")->fromIso3('MEX'); // return "522281694545"
$phonecode->makeFull("2281694545")->fromIso3('mex'); // return "+522281694545" 

$phonecode->getAll(); // return all data as collection

//STATICS FUNCTIONS

PhoneCode::isCodeOf(51);   // "Peru"
PhoneCode::codeOf("Peru"); // "51"
$items = PhoneCode::get(); // return a collection

// Working with collections

$item  = $items->first();

$item->phone_code; // "93
$item->nombre; // "Afganistán"
$item->name; // "Afghanistan"
$item->iso2; // "AF"
$item->iso3; // "AFG" 


$items->firstWhere('name', "Peru");

/*
{
  "nombre": "Perú"
  "name": "Peru"
  "nom": "Pérou"
  "iso2": "PE"
  "iso3": "PER"
  "phone_code": "51"
}
*/

- You can implement any functionality of the laravel collections.
- See https://laravel.net.cn/docs/7.x/collections

配置

php artisan vendor:publish --tag=config

这会将所有配置选项发布到:config/phone-code.php。您可以添加新的值。

测试

composer test

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

贡献

请参阅CONTRIBUTING以获取详细信息。

安全

如果您发现任何与安全相关的问题,请通过电子邮件aquinoaldair@hotmail.com联系,而不是使用问题跟踪器。

致谢

许可

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

Laravel包模板

此包是用Laravel包模板生成的。