<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('duty_calendars', function (Blueprint $table) {
            $table->id();
            $table->foreignId('employee_id')->constrained('users');
            $table->foreignId('duty_schedule_id')->nullable()->constrained();
            $table->date('date');
            $table->foreignId('holiday_id')->nullable()->constrained();
            $table->foreignId('leave_id')->nullable()->constrained('leave_requests');
            $table->tinyInteger('is_weekend')->nullable()->default(0)->comment('0 => No, 1 => Yes');
            $table->tinyInteger('is_take_meal')->nullable()->default(0)->comment('0 => No, 1 => Yes');
            $table->foreignId('created_by')->default(1)->constrained('users');
            $table->foreignId('updated_by')->nullable()->constrained('users');

            $table->unsignedBigInteger('company_id')->nullable()->default(1);
            $table->unsignedBigInteger('branch_id')->nullable()->default(1);
            $table->timestamps();
        });
    }

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