title: Laravel: UpdateOrCreate on Relation?
body: <p>A user <strong>hasOne</strong> car. </p>
  
  <p><strong>users</strong></p>
  
  <pre><code>id | name
  1  | Bob
  2  | Alice
  </code></pre>
  
  <p><strong>cars</strong></p>
  
  <pre><code>idMember |  color  |  energy
     1     |  blue   |    0.95
  </code></pre>
  
  <p>Inside the <strong>User</strong> class I have</p>
  
  <pre><code>public function car()
  {
    return $this-&gt;hasOne('App\Car','idMember');
  }
  </code></pre>
  
  <p>I want to call updateOrCreate on the relation Model like this:</p>
  
  <pre><code>$user-&gt;car()-&gt;updateOrCreate(['idMember' =&gt; $user-&gt;id], ['color' =&gt; 'red', 'energy' =&gt; '0.1']); 
  </code></pre>
  
  <p>However, I get the error message</p>
  
  <blockquote>
    <p>"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where
    clause' (SQL: update <code>cars</code> set <code>color</code> = red, <code>energy</code> = 0.1,
    <code>updated_at</code> = 2018-01-12 15:26:47 where <code>id</code> is null)</p>
  </blockquote>
  
  <p>Why is he looking for </p>
  
  <blockquote>
    <p><code>id</code> is null </p>
  </blockquote>
  
  <p>?</p>