<?php

namespace App\Imports;

use App\Models\User;
use Maatwebsite\Excel\Concerns\ToModel;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\WithStartRow;

class UsersImport implements ToModel, WithStartRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */

    public function startRow(): int
    {
        return 2;
    }

    public function model(array $row)
    {
        return new User([
            // 'id'     => $row[0],
            // 'email'    => $row[1], 
            // 'password' => Hash::make($row[2]),
            'id'     => $row[0],
            'first_name'=> $row[1],
            'second_name'=> $row[2],
            'midell_name'=> $row[3],
            'last_name'=> $row[4],
            'roles_name'=> $row[5],
            'user_type'=> $row[6],
            'email'=> $row[7],
            'email_verified_at'=> $row[8],
            'password'=> Hash::make($row[9]) ,
            'dept_id'=> $row[10],
            //'gender_id'=> $row[11],
            'phone'=> $row[11],
            //'nationalitie_id'=> $row[13],
            //'address'=> $row[14],
            'certificats'=> $row[12],
            'remember_token'=> $row[13],
            'deleted_at'=> $row[14],
            'created_at'=> $row[15],
            'updated_at'=> $row[16],
        ]);
    }
}
