<?php

namespace App\Imports;

use App\Models\Lead;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class LeadsImport implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new Lead([
            'name' => $row['name'],
            'email' => $row['email'] ?? null,
            'phone' => $row['phone'],
            'source_id' => $row['source_id'] ?? null,
            'status_id' => $row['status_id'] ?? null,
        ]);
    }
}
