title: Overriding attach method from belongsToMany relationship
body: <p>I want to add an attribute on a pivot table on every attach/save in a  belongsToMany relationship. </p>
  
  <p>Example:</p>
  
  <pre><code>// I don't want to do add the `rand` attribute everytime...
  User::find(1)-&gt;roles()-&gt;save($role, ['rand' =&gt; rand()]);
  User::find(7)-&gt;roles()-&gt;save($role, ['rand' =&gt; rand()]);
  User::find(42)-&gt;roles()-&gt;save($role, ['rand' =&gt; rand()]);
  
  // ... I just want to call save...
  User::find(1)-&gt;roles()-&gt;save($role);
  // ... and magically, `rand` attribute is set to rand()
  </code></pre>
  
  <p>I wanted to overload <code>belongsToMany</code> function in Model, but it does not look like to be a good solution, it looks like a hack. Because doing this, I have to create a new <code>BelongsToMany</code> class extending the original one, call the original <code>attach</code> method in <code>Model</code>, then override the returned object, and then my code becomes spaghetti, so I threw everything.</p>
  
  <p>Is there any elegant way to do this?</p>
  
  <p><em>Side note: <code>rand</code> attribute is a stupid example, it's just an illustration, don't care about it.</em></p>