<?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('payments', function (Blueprint $table) {

            $table->string('payment_method')
                ->nullable()
                ->after('payment_id');

            $table->string('reference_number')
                ->nullable()
                ->after('payment_method');

            $table->text('remarks')
                ->nullable()
                ->after('reference_number');

            $table->boolean('is_manual')
                ->default(false)
                ->after('remarks');

            $table->foreignId('recorded_by')
                ->nullable()
                ->after('is_manual')
                ->constrained('users')
                ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('payments', function (Blueprint $table) {

            $table->dropForeign([
                'recorded_by'
            ]);

            $table->dropColumn([
                'payment_method',
                'reference_number',
                'remarks',
                'is_manual',
                'recorded_by',
            ]);
        });
    }
};