File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Moox \Data \Console \Commands ;
6+
7+ use Illuminate \Console \Command ;
8+ use Moox \Data \Models \StaticLocale ;
9+
10+ class UpdateLocaleFlagCountryCodes extends Command
11+ {
12+ protected $ signature = 'moox:data:update-locale-flags ' ;
13+
14+ protected $ description = 'Update flag_country_code for all static locales ' ;
15+
16+ public function handle (): void
17+ {
18+ $ this ->info ('Updating flag country codes for locales... ' );
19+
20+ $ locales = StaticLocale::all ();
21+ $ count = 0 ;
22+
23+ foreach ($ locales as $ locale ) {
24+ if ($ locale ->country ?->alpha2) {
25+ $ locale ->flag_country_code = $ locale ->country ->alpha2 ;
26+ $ locale ->save ();
27+ $ count ++;
28+ }
29+ }
30+
31+ $ this ->info ("Updated {$ count } locales with flag country codes. " );
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -42,10 +42,6 @@ public function country()
4242
4343 public function getLanguageFlagIconAttribute (): ?string
4444 {
45- if (! $ this ->flag_country_code ) {
46- return null ;
47- }
48-
4945 return match ($ this ->language ?->alpha2) {
5046 'ar ' => 'flag-ar_arab ' ,
5147 default => 'flag- ' .strtolower ($ this ->flag_country_code ),
You can’t perform that action at this time.
0 commit comments