<?php

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

class AddLeaveCategories extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::table('categories')->insert([
            [
                'c_code' => 'LEAVE_WITHOUT_PAY',
                'c_name' => 'Không phép',
                'c_type' => 'REASON_NOTES',
                'c_value' => "",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'WFH',
                'c_name' => 'Work From Home',
                'c_type' => 'REASON_NOTES',
                'c_value' => "",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'c_code' => 'ONLEAVE',
                'c_name' => 'Nghỉ phép',
                'c_type' => 'REASON_NOTES',
                'c_value' => "",
                'c_active' => 1,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::table('categories')
            ->whereIn('c_code', ['LEAVE_WITHOUT_PAY', 'WFH', 'ONLEAVE'])
            ->where('c_type', 'REASON_NOTES')
            ->delete();
    }
}
