<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->id();
            $table->string('c_code');
            $table->string('c_name');
            $table->string('c_type');
            $table->string('c_value');
            $table->integer('c_active');
            $table->timestamps();
        });

        DB::table('categories')->insert([
            [
                'c_code' => 'S',
                'c_name' => 'Buổi Sáng',
                'c_type' => 'TIME_TYPE',
                'c_value' => "0.5",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'C',
                'c_name' => 'Buổi Chiều',
                'c_type' => 'TIME_TYPE',
                'c_value' => "0.5",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'ALL',
                'c_name' => 'Cả Ngày',
                'c_type' => 'TIME_TYPE',
                'c_value' => "1",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'WFH',
                'c_name' => 'Work From Home',
                'c_type' => 'REASON',
                'c_value' => null,
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'ONLEAVE',
                'c_name' => 'Nghỉ phép',
                'c_type' => 'REASON',
                'c_value' => null,
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);
    }

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