<?php

namespace Database\Seeders;

use App\Enums\UserType;
use App\Models\SalaryCertificateRequest;
use App\Models\User;
use Illuminate\Database\Seeder;

class SalaryCertificateRequestSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $employees = \App\Models\User::where('type', 'employee')->limit(3)->get();
        $admin = \App\Models\User::where('type', 'super-admin')->first();

        foreach ($employees as $index => $employee) {
            \App\Models\SalaryCertificateRequest::updateOrCreate(
                ['user_id' => $employee->id, 'reason' => 'Bank loan application'],
                [
                    'status' => $index === 0 ? 'approved' : 'pending',
                    'approved_by' => $index === 0 ? $admin->id : null,
                    'approved_at' => $index === 0 ? now() : null,
                ]
            );
        }
    }
}
