Files
RomhackPlaza/app/Console/Commands/MigrateTaxonomiesConfigure.php
2026-06-23 19:24:38 +02:00

45 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
#[Signature('migrate:taxonomies:configure')]
#[Description('Configure taxonomies table.')]
class MigrateTaxonomiesConfigure extends Command
{
public function handle()
{
$taxonomyMap = [];
$taxonomy = "a";
$tableName = "";
while( $taxonomy !== "" ){
$taxonomy = "";
$tableName = "";
$taxonomy = $this->ask("Write WP taxonomy name. Write nothing if you want to save changes.", "" );
if( $taxonomy == "" )
break;
$tableName = $this->ask("Write equivalent Laravel table name.");
$taxonomyMap[$taxonomy] = $tableName;
}
DB::table('migration_settings')
->updateOrInsert([
'key' => 'wp_taxonomies_to_laravel_tables'
],[
'value' => json_encode($taxonomyMap), 'updated_at' => now()
]);
$this->info('WP Taxonomies to Laravel tables have been configured.');
}
}