<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (! Schema::hasTable('platform_settings')) {
            return;
        }

        DB::table('platform_settings')
            ->where('group', 'branding')
            ->where('key', 'landing_page_cta_text')
            ->where(function ($query): void {
                $query
                    ->where('value', 'Find My Best Remote Matches')
                    ->orWhere('value', '"Find My Best Remote Matches"')
                    ->orWhereNull('value');
            })
            ->update([
                'value' => '"Get Matched"',
                'updated_at' => now(),
            ]);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (! Schema::hasTable('platform_settings')) {
            return;
        }

        DB::table('platform_settings')
            ->where('group', 'branding')
            ->where('key', 'landing_page_cta_text')
            ->where('value', '"Get Matched"')
            ->update([
                'value' => '"Find My Best Remote Matches"',
                'updated_at' => now(),
            ]);
    }
};
