Receive all attributes of all 250 countries worldwide with Laravel Rinvex Country
Omranic built a useful package that we can use to retrieve country details with flexibility.
A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, and other attributes for all 250 countries worldwide at your fingertips.
Quick Example (TL;DR)
Install via composer require rinvex/country, then use as follows:
use Rinvex\Country\Models\Country; // Find a country by it's ISO 3166-1 alpha-2 $egypt = (new Country)->find('EG'); // Find a country by one of it's attributes $usa = (new Country)->findBy('capital', 'Washington D.C.'); // Find all countries $countries = (new Country)->findAll(); // Retrieve only `name`, `demonym`, and `currency` attributes of "Japan": $japan = (new Country)->find('JP', ['name', 'demonym', 'currency']); // Utilize Laravel Collections to get an array of all country names, with their 'iso_3166_1_alpha2' as the array keys $allCountries = (new Country)->findAll()->pluck('name.common', 'iso_3166_1_alpha2');
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Packages Laravel 5 Laravel 5.1 Laravel 5.2 Laravel 5.3 Intermediate Sources