<?php

namespace Database\Seeders;

use App\Models\EmployeeSalaryAssignment;
use App\Models\PayrollStructure;
use App\Models\User;
use Illuminate\Database\Seeder;

class EmployeeSalaryAssignmentSeeder extends Seeder
{
    public function run(): void
    {
        $structure = PayrollStructure::where('name', '6am_payroll')->first();
        $employees = User::where('type', 'employee')->get();

        foreach ($employees as $employee) {
            EmployeeSalaryAssignment::updateOrCreate(
                ['employee_id' => $employee->id],
                [
                    'payroll_structure_id' => $structure->id,
                    'salary_type' => 'monthly',
                    'gross_salary' => rand(3000, 8000),
                    'effective_from' => now()->subYear(),
                ]
            );
        }
    }
}
