title: Laravel attach pivot to table with multiple values
body: <h3>Background</h3>
  
  <p>I'm creating a database revolving around food allergies and I have a many to many relationship between foods and allergies. There is also a pivot value called <code>severity</code> which has a numerical number representing the severity of the allergy for that food item.</p>
  
  <p>This link table looks like this;</p>
  
  <pre><code>food_id|allergy_id|severity
  -------|----------|--------
       1 |        1 |      3
       1 |        4 |      1
       2 |        2 |      1
  </code></pre>
  
  <h3>The problem</h3>
  
  <p>When trying to update the link table with Eloquent (where <code>$allergy_ids</code> is an array)</p>
  
  <pre><code>$food-&gt;allergies()-&gt;attach($allergy_ids);
  </code></pre>
  
  <p>How would I go about adding multiple values to this pivot table at once along with the pivot values?</p>
  
  <p>I can add all the <code>allergy_id</code>'s for a particular food item in one go using the above line, but how can I also add in the <code>severity</code> column at the same time with an array of various severity values? Maybe something like</p>
  
  <pre><code>$food-&gt;allergies()-&gt;attach($allergy_ids, $severity_ids);
  </code></pre>
  
  <p>Edit: There could be between 0-20 allergies for a specific food item, and a severity rating from 0-4 for each allergy, if this helps at all.</p>