mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
34 lines
980 B
PHP
34 lines
980 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Database;
|
|
|
|
use App\Models\Country;
|
|
use Illuminate\Console\Command;
|
|
|
|
class MigrateCountriesTableCommand extends Command
|
|
{
|
|
protected $signature = 'database:migrate-countries-table';
|
|
|
|
protected $description = 'Migrate countries table by creating new entries from iso codes';
|
|
|
|
public function handle(): void
|
|
{
|
|
$this->output->progressStart(\WW\Countries\Models\Country::count());
|
|
|
|
foreach (\WW\Countries\Models\Country::all() as $country) {
|
|
Country::query()
|
|
->updateOrCreate(
|
|
['code' => str($country->iso_code)->lower()],
|
|
[
|
|
'name' => $country->name,
|
|
'english_name' => $country->name,
|
|
],
|
|
);
|
|
$this->output->progressAdvance();
|
|
}
|
|
|
|
$this->output->progressFinish();
|
|
$this->info('🌍 Countries migrated successfully! 🎉');
|
|
}
|
|
}
|