d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Provide Country and Other Locale Data in Laravel

Laravel World is a package providing a list of the countries, states, cities, currencies, and timezones. World integrates data with Eloquent models via the database and provides facades, helpers, and API routes:

1use NnjeimWorldWorld;

2 

3$action = World::countries();

4/*

5{

6 "success": true,

7 "message": "countries",

8 "data": [

9 {

10 "id": 1,

11 "name": "Afghanistan"

12 },

13 {

14 "id": 2,

15 "name": "Åland Islands"

16 },

17 ...

18 ],

19}

20*/

Here’s another example from the readme using filters to fetch a country and cities within the country:

1// Fetch a country and cities

2$action = World::countries([

3 'fields' => 'states,cities',

4 'filters' => [

5 'iso2' => 'FR',

6 ]

7]);

8/*

9{

10 "success": true,

11 "message": "countries",

12 "data": [

13 "id": 77,

14 "name": "France",

15 "states": [

16 {

17 "id": 1271,

18 "name": "Alo"

19 },

20 {

21 "id": 1272,

22 "name": "Alsace"

23 },

24 ],

25 "cities": [

26 {

27 "id": 25148,

28 "name": "Abondance"

29 },

30 {

31 "id": 25149,

32 "name": "Abrest"

33 },

34 ...

35 ]

36 ],

37}

38*/

This package also supports localization (see the readme for supported locales), provides API endpoints for all the data, and has helpers for formatting phone numbers, etc.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks


Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this