title: Inserting multiple records in a form
body: <p>I am trying to insert several records at once from a form
  <a href="https://i.stack.imgur.com/3fxNO.png" rel="nofollow noreferrer">This is how the form appears</a></p>
  
  <pre><code>     &lt;label&gt;Drug&lt;/label&gt;
          &lt;select class="form-inline input-sm " name="drug[]" id="drug"&gt;
               @foreach($drugs as $key =&gt; $drug)
                      &lt;option value="{{$drug-&gt;id}}"&gt; {{$drug-&gt;name}}&lt;/option&gt;
               @endforeach
           &lt;/select&gt;
  
        &lt;input class="input-sm" type="number" class="form-control" id="amount_received" name="amount_received[]" placeholder="Amount received"&gt;
  
        &lt;button type="button" name="add" id="add"&gt;Add More&lt;/button&gt;
  
        &lt;button type="submit" class="btn btn-primary"id="submit"&gt;Submit&lt;/button&gt;
  </code></pre>
  
  <p>My controller</p>
  
  <pre><code>public function addNewStock()
  {
      $input = Input::all();
      $insert = array();
      foreach($input['drug'] as $key =&gt; $drug) {
          $insert[$key]['drug'] = $drug;
      }
      foreach($input['amount_received'] as $item =&gt; $amount_received) {
          $insert[$item]['amount_received'] = $amount_received;
      }
      Stock::insert($insert);
  
  }
  </code></pre>
  
  <p>This is the result i get when i dd($input). This is after i submit two record, problem is it picks the last record and saves i twice in the database</p>
  
  <pre><code>array:3 [▼
    "_token" =&gt; "Oz9cSvNuPmPPHKAw6uKbnmA5DIMBsxKsnubaliHt"
    "drug" =&gt; array:2 [▼
      0 =&gt; "1"
  1 =&gt; "10"
    ]
    "amount_received" =&gt; array:2 [▼
  0 =&gt; "2"
  1 =&gt; "4"
    ]
  ]
  </code></pre>
  
  <p>Kindly assist.</p>