title: Integrity constraint violation: Column cannot be null Error
body: <p>I'm using <code>Maatwebsite\Excel</code> to export and store data from an <code>Excel</code> file. I'm getting an error: <code>Integrity constraint violation: 1048 Column delegate_id cannot be null Error</code> which says that the column can't be <code>Null</code>. However I'm affecting a value to <code>delegate_id</code> but I'm still getting that error message. Is there something wrong with my code below?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public function model(array $row) {
    $delegate = Delegate::where('email',$row['mail'])-&gt;first();
    if (!$delegate) {
      $delegate = new Delegate([
                  'name' =&gt; $row["name"],
                  'phone' =&gt; $row["tel"],
                  'email' =&gt; $row["mail"]]);
    }
    
    $newZipcode = new Zipcode();
    $newDelegateZipcode-&gt;zipcode = $row["cp"];
  
    $data = DB::table('delegates')-&gt;latest()-&gt;first();
  
    if ($data === null) {
      $newZipcode-&gt;delegate_id = 0;
    } else {
      if ($delegate-&gt;id === null) {
        $newZipcode-&gt;delegate_id = $data-&gt;id + 1;
      } else {
        $newZipcode-&gt;delegate_id = $delegate-&gt;id;
      }
    }
  
    $newZipcode-&gt;delegate()-&gt;associate($delegate);
    $newZipcode-&gt;save();
    
    return $delegate;
  }</code></pre>
  </div>
  </div>
  </p>