<?php

namespace Database\Seeders;

use App\Enums\EmployeeAdvanceStatus;
use App\Models\EmployeeAdvance;
use App\Models\LeaveRequest;
use App\Models\Rejection;
use App\Models\User;
use Illuminate\Database\Seeder;

class RejectionSeeder extends Seeder
{
    public function run(): void
    {
        $user = User::query()->first();

        if ($user === null) {
            return;
        }

        $advance = EmployeeAdvance::factory()->create([
            'status' => EmployeeAdvanceStatus::REJECTED->value,
            'verified_at' => now(),
            'verified_by_id' => $user->id,
        ]);

        Rejection::factory()->create([
            'rejectable_type' => EmployeeAdvance::class,
            'rejectable_id' => $advance->id,
            'rejected_by_id' => $user->id,
        ]);

        $leaveRequest = LeaveRequest::factory()->rejected()->create([
            'verified_by_id' => $user->id,
        ]);

        Rejection::factory()->create([
            'rejectable_type' => LeaveRequest::class,
            'rejectable_id' => $leaveRequest->id,
            'rejected_by_id' => $user->id,
        ]);
    }
}
