<?php

namespace App\Imports;

use App\Models\GetDren;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToArray;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class DrenImport implements ToArray, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function array(array $data)
    {
        $i = 1;
        while($i < sizeof($data)){
            GetDren::create([
                'libelle' => $data[$i][1],
                'email' => strtolower($data[$i][2])
            ]);
            $i++;
        }
    }
}
