title: Laravel - Saving to pivot table in many to many relationship with extra column
body: <p>I have models <code>Transaction</code> and <code>Option</code>, that have many to many relationship. The pivot table <code>transaction_options</code> has columns <code>transaction_id</code>, <code>option_id</code> and <code>price</code>.
  I have defined the relationships in the models like this:</p>
  
  <p><strong>Transaction</strong> model:</p>
  
  <pre><code>public function options()
  {
      return $this-&gt;belongsToMany('App\Option', 'transaction_options')-&gt;withPivot('price');
  }
  </code></pre>
  
  <p><strong>Option</strong> model:</p>
  
  <pre><code>public function transactions()
  {
      return $this-&gt;belongsToMany('App\Transaction', 'transaction_options')-&gt;withPivot('price');
  }
  </code></pre>
  
  <p>I am wondering how can I save something in the pivot table, I have tried something like this, but it is not working:</p>
  
  <pre><code>   foreach($data-&gt;options as $option) {
          $transaction-&gt;options()-&gt;create([
              'transaction_id' =&gt; $transaction-&gt;id,
              'extras_id'      =&gt; $option-&gt;extraId,
              'option_id'      =&gt; $option-&gt;id,
              'price'          =&gt; $option-&gt;price
          ]);
      }
  </code></pre>
  
  <p>How can I do this?</p>