<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\EmpDep;
use App\Models\Employee;

class EmployeeSeeder extends Seeder
{
    public function run(): void
    {
        $departments = [
            'Madalasa Hospital' => [
                ['name'=>'Amit Sharma','email'=>'amit@madalasa.com','designation'=>'Nurse','location'=>'Ward A'],
                ['name'=>'Ravi Kumar','email'=>'ravi@madalasa.com','designation'=>'Technician','location'=>'Lab'],
            ],
            'PAC' => [
                ['name'=>'Neha Verma','email'=>'neha@pac.com','designation'=>'Analyst','location'=>'HQ'],
                ['name'=>'Suresh Gupta','email'=>'suresh@pac.com','designation'=>'Manager','location'=>'HQ'],
            ],
            'Gurukool Hub' => [
                ['name'=>'Sonia Jain','email'=>'sonia@gurukool.com','designation'=>'Trainer','location'=>'Center 1'],
            ],
            'Internal Auditor' => [
                ['name'=>'Anil Mehta','email'=>'anil@audit.com','designation'=>'Auditor','location'=>'Audit Dept'],
            ],
        ];

        foreach ($departments as $depName => $emps) {
            $dep = EmpDep::firstOrCreate(['name'=>$depName]);
            foreach ($emps as $emp) {
                Employee::firstOrCreate(
                    ['email'=>$emp['email']],
                    [
                        'emp_dep_id'=>$dep->id,
                        'name'=>$emp['name'],
                        'designation'=>$emp['designation'],
                        'location'=>$emp['location'],
                        'status'=>'active'
                    ]
                );
            }
        }
    }
}
