title: Laravel Maatwebsite/Laravel-Excel Update if exist
body: <p>I'm using This Package <a href="https://github.com/maatwebsite/Laravel-Excel" rel="nofollow noreferrer">Maatwebsite/Laravel-Excel</a> to import data from excel file</p>
  <p>what I wanna do is check if the column exists before import data from excel file,</p>
  <p>if so, then update otherwise insert</p>
  <p>Model:</p>
  <pre><code>&lt;?php
  
  namespace App\Imports;
  
  use App\Medicine;
  use Carbon\Carbon;
  use Maatwebsite\Excel\Concerns\ToModel;
  use Maatwebsite\Excel\Concerns\WithHeadingRow;
  use Maatwebsite\Excel\Imports\HeadingRowFormatter;
  
  HeadingRowFormatter::default('none');
  class MedicineImport implements ToModel, WithHeadingRow
  {
      protected $company_id;
  
      public function __construct($company_id)
      {
          $this-&gt;company_id = $company_id;
      }
      /**
      * @param array $row
      *
      * @return \Illuminate\Database\Eloquent\Model|null
      */
      public function model(array $row)
      {
          $expire_date = empty($row['Expire Date']) ? $row['Expire Date'] : Carbon::instance(\PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['Expire Date']));
          return new Medicine([
              'name'         =&gt; $row['Name'],
              'price'        =&gt; $row['Price'],
              'expire_date'  =&gt; $expire_date,
              'company_id'    =&gt; $this-&gt;company_id,
  
          ]);
      }
  }
  </code></pre>
  <p>Controller:</p>
  <pre><code>$company = Company::where('id',$id)-&gt;first();
      $medicines=DB::table('medicines')-&gt;where('company_id', $id)-&gt;delete();
      $company_id= $id;
      Excel::import(new MedicineImport($company_id),request()-&gt;file('file'));
  
      return redirect()-&gt;route('company.medicine.index',$company_id);
  </code></pre>
  <p>any ideas to do this?</p>