title: Update order in pivot table when using sync in Laravel
body: <p>In Laravel 4.2, I have the following code:</p>
  
  <pre><code>    $thingIds = [];
      foreach ($this-&gt;things as $thing) {
          $thingIds[] = $thing-&gt;id;
      }
      $thong-&gt;things()-&gt;sync($thingIds);
      $thong-&gt;save();
  </code></pre>
  
  <p>Which seems to work for me, however in my pivot table I have an <code>order</code> column that isnt being updated/synced correctly.  The order is set to 1 for each item in the pivot table, however I want the order to be representative of the order of the ids in <code>$thingIds</code>.</p>
  
  <p>Is this possible?</p>
  
  <p>Is it possible to update an additional column in the pivot table using <code>-&gt;sync()</code>?</p>
  
  <hr>
  
  <p>After the suggestion in the comments, I have also tried the following code:</p>
  
  <pre><code>    $thingIds = [];
      foreach ($this-&gt;things as $index =&gt; $thing) {
          $thingIds[$thing-&gt;id] = ['order' =&gt; $index];
      }
      $thong-&gt;things()-&gt;sync($thingIds);
      $thong-&gt;save();
  </code></pre>
  
  <p>And I have tried</p>
  
  <pre><code>    $thingIds = [];
      $order = [];
      foreach ($this-&gt;things as $index =&gt; $thing) {
          $thingIds[] = $thing-&gt;id;
          $order[] = ['order' =&gt; $index];
      }
      $thong-&gt;things()-&gt;sync(array_combine($thingIds, $order));
      $thong-&gt;save();
  </code></pre>
  
  <p>But neither of these is working (the order is still 1 for each item in the pivot table).  Can anyone explain what I am doing wrong?</p>
  
  <hr>
  
  <p>If I do the attaching one at a time, like so:</p>
  
  <pre><code>    foreach ($this-&gt;things as $index =&gt; $thing) {
          $thong-&gt;things()-&gt;attach($thing, ['order' =&gt; $index]);
      }
  </code></pre>
  
  <p>The order comes out correctly in the pivot table.  How can I get the same effect but whilst still using <code>-&gt;sync()</code>?</p>