<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            // Kita tambahkan kolom yang belum ada di tabel orders lama
            $table->string('customer_name')->nullable()->after('order_number');
            $table->string('customer_phone')->nullable()->after('customer_name');
            $table->text('customer_address')->nullable()->after('customer_phone');
            $table->string('destination_area_id')->nullable()->after('customer_address');
            $table->string('postal_code', 10)->nullable()->after('destination_area_id');
            $table->decimal('subtotal', 10, 2)->default(0)->after('postal_code');
            $table->string('payment_method')->default('qris')->after('status');
            $table->string('payment_proof')->nullable()->after('payment_method');
        });
    }

    public function down(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            $table->dropColumn([
                'customer_name',
                'customer_phone',
                'customer_address',
                'destination_area_id',
                'postal_code',
                'subtotal',
                'payment_method',
                'payment_proof'
            ]);
        });
    }
};