Skip to content

Commit e3546ab

Browse files
committed
Update StaticLocale.php
1 parent a7955f8 commit e3546ab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/data/src/Models/StaticLocale.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/**
1212
* @property-read \Moox\Data\Models\StaticLanguage|null $language
1313
* @property-read \Moox\Data\Models\StaticCountry|null $country
14+
* @property string $flag_country_code
1415
*/
1516
class StaticLocale extends Model
1617
{
@@ -41,6 +42,10 @@ public function country()
4142

4243
public function getLanguageFlagIconAttribute(): ?string
4344
{
45+
if (! $this->flag_country_code) {
46+
return null;
47+
}
48+
4449
return match ($this->language?->alpha2) {
4550
'ar' => 'flag-ar_arab',
4651
default => 'flag-'.strtolower($this->flag_country_code),
@@ -49,6 +54,10 @@ public function getLanguageFlagIconAttribute(): ?string
4954

5055
public function getCountryFlagIconAttribute(): ?string
5156
{
52-
return 'flag-'.strtolower($this->country?->alpha2);
57+
if (! $this->country?->alpha2) {
58+
return null;
59+
}
60+
61+
return 'flag-'.strtolower($this->country->alpha2);
5362
}
5463
}

0 commit comments

Comments
 (0)