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
Next.js Basics for Laravel Developers
11 lessons
58 min
Laravel 13 Starter Kit Teams and Customizations
10 lessons
33 min
Roles and Permissions in Laravel 13
14 lessons
57 min