<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('deduction_details', function (Blueprint $table) {
            $table->id();
            $table->foreignId('deduction_id')->constrained();
            $table->enum('deduction_type', ['Attendance', 'Leave']);
            $table->foreignId('tardy_rule_id')->nullable();
            $table->string('purpose');
            $table->decimal('amount')->default(0);
            $table->integer('days')->nullable();
            $table->string('comment')->nullable();
            $table->tinyInteger('is_applicable')->default(1);
            $table->foreignId('created_by')->constrained('users');
            $table->foreignId('updated_by')->nullable()->constrained('users');
            $table->foreignId('considered_by')->nullable()->constrained('users');
            $table->dateTime('considered_at')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('duduction_details');
    }
};
