petercoles / Multilingual-Country-List

Laravel wrapper for generating country lookups and data objects using the awesome country-list data
MIT License
141 stars 33 forks source link

Regions listed instead of countries. #3

Closed HarleyFuagras closed 7 years ago

HarleyFuagras commented 7 years ago

I have detected that not only countries are being listed but also some regions belonging to countries such as Canary Islands or Ceuta & Melilla wich are part of Spain. Is there any way to avoid this and list only countries? Thank you very much.

petercoles commented 7 years ago

The underlying list is the internationally recognised one, so I don't want to make (and then have to maintain) changes to that, but I see your point. There are politics involved in deciding what to include and sometimes that leads to undesirable results.

However, this package returns a highly manipulable collection. So for the example you've given, you could simply remove Canary Islands and Ceuta & Melilla from the results as follows:

Countries::lookup()->reject(function($country, $key) {
    return in_array($key, [ 'IC', 'TD' ]);
});