<?php

namespace App\Imports;

use App\Models\Employee;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Illuminate\Support\Facades\Hash;

class ImportEmployee implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        // dump($row);
        return Employee::updateOrCreate(
            ['employee_id' => isset($row['branch_code']) ? $row['branch_code'] : ""],
            [
                'employee_id' => isset($row['branch_code']) ? $row['branch_code'] : "",
                'employee_name' => isset($row['branch_name'])?$row['branch_name']:"Unknown",
                'password' => "HDFC12345",
            ]
        );
        // return new Employee([
        //     'employee_id' => isset($row['branch_code']) ? $row['branch_code'] : "",
        //     'employee_name' => isset($row['branch_name'])?$row['branch_name']:"Unknown",
        //     // 'email' => isset($row['employee_email'])?$row['employee_email']:NULL,
        //     // 'mobile_number' => isset($row['employee_mobile_number'])?$row['employee_mobile_number']:NULL,
        //     // 'whatsapp_number' => isset($row['employee_whatsapp_number'])?$row['employee_whatsapp_number']:NULL,
        //     // 'temp_password' => isset($row['temp_password'])?$row['temp_password']:NULL,
        //     'password' => "HDFC12345",
        // ]);
    }
}
