Skip to main content
Back to packages
975 GitHub stars

nnjeim/world

View on GitHub

Description

Laravel package which provides a list of the countries, states, cities, timezones, currencies and languages.

List all the countries

Use the World facade:

use Nnjeim\World\World;
 
$action = World::countries();
 
if ($action->success) {
$countries = $action->data;
}
 
response (object)
{
"success": true,
"data": [
{
"id": 1,
"name": "Afghanistan"
},
{
"id": 2,
"name": "Åland Islands"
},
.
.
.
],
}

Use the API countries endpoint:

https://myDomain.local/api/countries

Fetch a country with its states and cities.

Use the World facade:

use Nnjeim\World\World;
 
$action = World::countries([
'fields' => 'states,cities',
'filters' => [
'iso2' => 'FR',
]
]);
 
if ($action->success) {
 
$countries = $action->data;
}

Response:

(object)
{
"success": true,
"data": [
"id": 77,
"name": "France",
"states": [
{
"id": 1271,
"name": "Alo"
},
{
"id": 1272,
"name": "Alsace"
},
.
.
.
],
"cities": [
{
"id": 25148,
"name": "Abondance"
},
{
"id": 25149,
"name": "Abrest"
},
.
.
.
]
],
}

Use the API countries endpoint:

https://myDomain.local/api/countries?fields=states,cities&filters[iso2]=FR

Recent Courses on Laravel Daily

[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks

7 lessons
43 min read

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Queues in Laravel 13

18 lessons
1 h 12 min read

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.