title: Laravel insert dynamic inputs into database
body: <p>I'm trying to save dynamic inputs in multiple rows in my database.</p>
  
  <p>This is a part of my form which are payments and dates.</p>
  
  <pre><code>                &lt;tr&gt;
                      &lt;td class="col-md-2"&gt;
                          {{Form::text('pay[]', '', ['class' =&gt; 'form-control number', 'placeholder' =&gt; ''])}}
                      &lt;/td&gt;
                      &lt;td class="col-md-2"&gt;
                          {{Form::text('payDate[]', '', ['class' =&gt; 'form-control pDate', 'placeholder' =&gt; ''])}}
                      &lt;/td&gt;
                      &lt;td class="col-md-2"&gt;&lt;a class="deleteRow"&gt;&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
  </code></pre>
  
  <p>My JS code that add inputs dynamically:</p>
  
  <pre><code>$(document).ready(function () {
  var counter = 0;
  
  $("#addrow").on("click", function () {
      var newRow = $("&lt;tr&gt;");
      var cols = "";
  
      cols += '&lt;td&gt;&lt;input type="text" id="field_2" class="form-control" name="pay[]" /&gt;&lt;/td&gt;';
      cols += '&lt;td&gt;&lt;input type="text" class="form-control pDate" name="payDate[]" /&gt;&lt;/td&gt;';
      cols += '&lt;td&gt;&lt;input type="button" class="ibtnDel btn btn-md btn-danger "  value="Delete"&gt;&lt;/td&gt;';
  
      newRow.append(cols);
      $("table.order-list").append(newRow);
      counter++;
  });
  </code></pre>
  
  <p>And this is my Controller:</p>
  
  <pre><code>    $input = $request-&gt;all();
      for($i=0; $i&lt;= count($input['pay']); $i++) {
          $payment = new Payment;
          $payment-&gt;file = $file;
          $prePayment = str_replace(',', '', $request-&gt;input('pay'));
          $payment-&gt;payment = $prePayment;
          $payment-&gt;paymentDate = $request-&gt;input('payDate');
          $payment-&gt;save();
      }
  </code></pre>
  
  <p>Could you please help me to fix this issue.</p>
  
  <p>At the moment I get this error: </p>
  
  <p>Array to string conversion (SQL: insert into <code>payments</code> (<code>file</code>, <code>payment</code>, <code>paymentDate</code>, <code>updated_at</code>, <code>created_at</code>) values ....</p>