<?php

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

/**
 * An English label for the navbar call to action.
 *
 * Every other headline setting already comes in a pair (site_title /
 * site_title_en), but the navbar's own button did not — so a bilingual site had
 * to show one language's label to both audiences. Nullable, and the navbar
 * falls back to the Arabic label, so nothing changes for a site that never
 * fills it in.
 */
return new class extends Migration
{
    public function up(): void
    {
        if (! Schema::hasTable('website_settings')) {
            return;
        }

        Schema::table('website_settings', function (Blueprint $table) {
            if (! Schema::hasColumn('website_settings', 'navbar_cta_text_en')) {
                $table->string('navbar_cta_text_en', 100)->nullable()->after('navbar_cta_text');
            }
        });
    }

    public function down(): void
    {
        if (! Schema::hasTable('website_settings')) {
            return;
        }

        Schema::table('website_settings', function (Blueprint $table) {
            if (Schema::hasColumn('website_settings', 'navbar_cta_text_en')) {
                $table->dropColumn('navbar_cta_text_en');
            }
        });
    }
};
