Skip to content

Commit 76e8989

Browse files
committed
fix Territory to Country
1 parent f4f0c62 commit 76e8989

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/data/src/Models/StaticCountry.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ public function timezones()
7171

7272
public function getFlagIconAttribute(): ?string
7373
{
74-
return 'flag-'.strtolower($this->alpha2);
74+
$territoryToCountryMap = [
75+
'hm' => 'au', // Heard Island and McDonald Islands -> Australia
76+
'um' => 'us', // US Minor Outlying Islands -> United States
77+
'bq' => 'nl', // Caribbean Netherlands -> Netherlands
78+
'bv' => 'no', // Bouvet Island -> Norway
79+
'sh' => 'gb', // Saint Helena -> United Kingdom
80+
'sj' => 'no', // Svalbard and Jan Mayen -> Norway
81+
];
82+
83+
$alpha2 = strtolower($this->alpha2);
84+
$flagCode = $territoryToCountryMap[$alpha2] ?? $alpha2;
85+
86+
return 'flag-' . $flagCode;
7587
}
7688
}

0 commit comments

Comments
 (0)