<?php

namespace Modules\HR\Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Modules\Core\Database\Seeders\Traits\DisableForeignKeys;
use Modules\Core\Enums\StatusEnum;
use Modules\HR\Models\LeavePolicy;
use Modules\HR\Models\LeaveType;

class LeavePolicySeeder extends Seeder
{
    use DisableForeignKeys, WithoutModelEvents;
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->disableForeignKeys();
        $leaveType = LeaveType::first();

        if ($leaveType) {
            LeavePolicy::create([
                'leave_type_id' => $leaveType->id,
                'annual_limit' => 10,
                'carry_forward' => true,
                'encashable' => true,
                'max_carry_forward_days' => 5,
                'status' => StatusEnum::ACTIVE,
            ]);
        }

        $this->enableForeignKeys();
    }
}
