<?php

namespace App\Imports;

use App\Models\Shop\Customer;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class CustomersImport implements ToModel, WithHeadingRow
{
    public function model(array $row)
    {
        $row['civilite'] = $row['civilite'] == 'M' ? 1 : 2;
        $row['cp'] = (string) $row['cp'];
        $row['mobile'] = '0' . (string) $row['mobile'];
        dump($row);
        return new Client(
            [
            'civilite' => $row['civilite'],
            'name' => $row['nom'],
            'firstname' => $row['prenom'],
            'street1' => $row['adresse'],
            'zipcode' => $row['cp'],
            'city' => $row['ville'],
            'mobile' => $row['mobile'],
            'email' => $row['email'],
            'phone' => $row['telephone'],
            ]
        );
    }
}
