<?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('utility_fees', function (Blueprint $table) {
            // 1. 將費用日期改為可為空 (繳費日期)
            $table->date('transaction_date')->nullable()->change();
            
            // 2. 新增繳費期限
            $table->date('due_date')->nullable()->after('transaction_date')->comment('繳費期限');
            
            // 3. 新增繳費狀態
            $table->enum('payment_status', ['pending', 'paid', 'overdue'])
                  ->default('pending')
                  ->after('amount')
                  ->comment('繳費狀態');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('utility_fees', function (Blueprint $table) {
            $table->date('transaction_date')->nullable(false)->change();
            $table->dropColumn(['due_date', 'payment_status']);
        });
    }
};
