title: Laravel save or update many to many relationship with additional column
body: <p>I have a many to many relationship set up in laravel where I want to save user settings. A setting can be set from many users and a user can have many settings.</p>
  
  <p>I have an additional field named "value" in the pivot table where I want to save the value set by the user.</p>
  
  <p>Well, what I want is to create a new entry when there is no value for the particular user and setting. But if there is already a value it should get updated.</p>
  
  <p>This is what I've tried:</p>
  
  <pre><code>$setting = Setting::find(1);
  Auth::user()-&gt;settings()-&gt;save($setting,array('value' =&gt; 15));
  </code></pre>
  
  <p>As soon as I change the value to something else it automatically creates a new entry. But I'd like it to be updated. How can I achieve this?</p>