<?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
    {
        // 1. Konfigurasi Dasar Kalender
        Schema::create('work_calendars', function (Blueprint $table) {
            $table->id();
            $table->string('year', 4);
            $table->integer('standard_work_days_per_week');
            $table->json('working_days');
            $table->timestamps();
        });

        // 2. Jadwal Libur (Dukung Libur Nasional & Cabang)
        Schema::create('holiday_schedules', function (Blueprint $table) {
            $table->id();
            $table->date('holiday_date');
            $table->string('description');
            $table->boolean('is_national_holiday')->default(true);
            $table->foreignId('branch_id')->nullable()->constrained('branches')->onDelete('cascade');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('holiday_schedules');
        Schema::dropIfExists('work_calendars');
    }
};