<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            if (!Schema::hasColumn('users', 'first_name')) { $table->string('first_name')->nullable(); }
            if (!Schema::hasColumn('users', 'last_name')) { $table->string('last_name')->nullable(); }
            if (!Schema::hasColumn('users', 'country')) { $table->string('country')->nullable(); }
            if (!Schema::hasColumn('users', 'country_code')) { $table->string('country_code', 10)->nullable(); }
            if (!Schema::hasColumn('users', 'city')) { $table->string('city')->nullable(); }
            if (!Schema::hasColumn('users', 'address')) { $table->text('address')->nullable(); }
            if (!Schema::hasColumn('users', 'whatsapp')) { $table->string('whatsapp', 20)->nullable(); }
            if (!Schema::hasColumn('users', 'is_banned')) { $table->boolean('is_banned')->default(false); }
            if (!Schema::hasColumn('users', 'ban_reason')) { $table->text('ban_reason')->nullable(); }
            if (!Schema::hasColumn('users', 'discount_percentage')) { $table->decimal('discount_percentage', 5, 2)->default(0); }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn([
                'first_name',
                'last_name',
                'country',
                'country_code',
                'city',
                'address',
                'whatsapp',
                'is_banned',
                'ban_reason',
                'discount_percentage'
            ]);
        });
    }
};


