title: Laravel: Eloquent how to update a model and related models in one go
body: <p>Does anyone know if it is possitble to do the folowing:</p>
  
  <p>Let's say we have a model called User and a model calledd BestFriend. The relation between the User and the best friend is 1:1.</p>
  
  <p>I would like for these cases be able to do something like this, change my city and the city of my friend at the same time.</p>
  
  <pre><code>$me = User::find(1);
  
  $me-&gt;update(array(
  'city' =&gt; 'amsterdam',
  'bestfriend.city' =&gt; 'amsterdam'
  ));
  </code></pre>
  
  <p>So basically I would like to know if Eloquent is smart enough to understand the relationship based on the array key 'bestfriend.city'.</p>
  
  <p>Thanks in advance for any help!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Found the solution on the Laravel forums but im posting it here as well if someone else is looking for the same thing :)</p>
  
  <p>In the model you add</p>
  
  <pre><code>// In your model...
  public function setBestFriendArrayAttribute($values)
  {
      $this-&gt;bestfriend-&gt;update($values);
  }
  </code></pre>
  
  <p>And then you can call it like this</p>
  
  <pre><code>$me-&gt;update(array(
      'city' =&gt; 'amsterdam',
      'BestFriendArray' =&gt; array(
          'city' =&gt; 'amsterdam'
      )
  ));
  </code></pre>
  
  <p>Works like a charm!</p>