Laravel 5.8 or higher, 6.x, 7.x
You can install the package via composer:
composer require aquinoaldair/phone-codeProperties:
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.com/docs/7.x/collections
php artisan vendor:publish --tag=config
This will publish all the configuration options to: config/phone-code.php. You can add new values.
composer testPlease see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.