<?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('employee_leaves', function (Blueprint $table) {
            // if (!Schema::hasColumn('employee_leaves', 'validated_by')) {
            //     $table->integer('validated_by')->nullable()->after('approved_at');
            // }
            
            if(!Schema::hasColumn('employee_leaves', 'validated_at')){
                $table->timestamp('validated_at')->nullable()->after('validated_by');
            }

            // if(!Schema::hasColumn('employee_leaves', 'received')){
            //     $table->boolean('received')->default(false)->after('validated_at');
            // }

        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('employee_leaves', function (Blueprint $table){
            $columns = [
                // 'validated_by',
                'validated_at',
                // 'received',
            ];

            foreach ($columns as $column) {
                if (Schema::hasColumn('employee_leaves', $column)) {
                    $table->dropColumn($column);
                }
            }
        });
    }
};
