Skip to content

Commit dfa5f28

Browse files
committed
wip
1 parent e3546ab commit dfa5f28

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

packages/data/src/Models/StaticLocale.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)