title: Import excel in laravel Array key
body: <p>I am trying to upload the file but when I give import I get the following error Undefined array key &quot;idEvento&quot;</p>
  <p>When I handle it by number that I start from scratch I do not get any error and insert into the database</p>
  <p>Event Model</p>
  <pre><code>    &lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Factories\HasFactory;
  use Illuminate\Database\Eloquent\Model;
  
  class Eventos extends Model
  {
      use HasFactory;
  
      protected $fillable = [
          'nombre',
          'idEvento',
          'idSede',
          'inicio',
          'fin',
          'idModalidad',
          'cupo',
          'valor',
      ];
  }
  </code></pre>
  <p>Import data function</p>
  <pre><code>public function importData(Request $request){
  
          $file = $request-&gt;file('documento');
  
          $validator = Validator::make(
              array(
                  'file' =&gt; $file,
              ),
              array(
                  'file' =&gt; 'file|max:5000|mimes:xlsx,xls',
              )
          );
  
          if ($validator-&gt;fails()) {
              return Redirect::to('conferencia/import');
         }
  
          $import = new EventosImport();
          Excel::import($import, request()-&gt;file('documento'));
          return view('conferencias.import', ['numRows'=&gt;$import-&gt;getRowCount()]);
          //return redirect()-&gt;to(url('conferencia'));
      }
  </code></pre>
  <p>Event import code</p>
  <pre><code>    &lt;?php
  
  namespace App\Imports;
  
  use App\Models\Eventos;
  use Maatwebsite\Excel\Concerns\ToModel;
  use Maatwebsite\Excel\Concerns\WithHeadingRow;
  
  class EventosImport implements ToModel, WithHeadingRow
  {
      private $numRows = 0;
      /**
      * @param array $row
      *
      * @return \Illuminate\Database\Eloquent\Model|null
      */
      public function model(array $row)
      {
          ++$this-&gt;numRows;
          return new Eventos([
              'nombre' =&gt; $row['nombre'],
              'idEvento' =&gt; $row['idEvento'],
              'idSede' =&gt; $row['idSede'],
              'inicio' =&gt; \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['inicio']),
              'fin' =&gt; \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['fin']),
              'idModalidad' =&gt; $row['idModalidad'],
              'cupo' =&gt; $row['cupo'],
              'valor' =&gt; $row['valor'],
          ]);
      }
  
      public function getRowCount(): int
      {
          return $this-&gt;numRows;
      }
  }
  </code></pre>
  <p>Image of the excel<a href="https://i.stack.imgur.com/2cqx6.png" rel="nofollow noreferrer">enter image description here</a></p>