rinvex / countries

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

Home Page:https://rinvex.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get country codes by region

sts-ryan-holton opened this issue · comments

Hi,

I'm developing a Laravel application based on SMS messaging. My application allows users to send messages to different regions, for example, Europe, Worldwide, US/Canada, Americas etc...

Does this package support fetching all country codes by a region?

For example:

EUR would fetch me all of the country codes for this region, which I could then, when validating a phone number check the country code exists.

Again, I'm evaluating whether I can install and invest some time into this package.

Hey @sts-ryan-holton, thanks for the good question.

Yep, you can do that using a couple of ways, for example:

// Get countries with where condition (continent: Europe)
$euCountries = \Rinvex\Country\CountryLoader::where('geo.continent', ['EU' => 'Europe']);

// Or get countries with where condition (region: Europe)
$euCountries2 = \Rinvex\Country\CountryLoader::where('geo.region', 'Europe');

Check here a couple more usage examples https://github.com/rinvex/countries#usage