So I've created a form that that will submit to two separate tables. It's for invoice building. Each invoice has a variable amount of rows, so I've created two tables, one for the invoice and one for each row. The rows are tied to the invoice table via a foreign key.
With pure PHP it's simply a matter of naming the inputs "name[]" and then looping through them. But in Laravel, it's not seeming to work. Basically, I have:
$invoice = new Invoice;
$invoice->fill($data);
$invoice->save();
for ($i = 0; $i < count($request->item); $i++){
$row = new InvoiceRow;
$row->fill(array('item' => $request->item[$i], 'description' => $request->description[$i], 'cost' => $request->cost[$i], 'quantity' => $request->quantity[$i], 'total' => $request->itemTotal[$i]));
$invoice->InvoiceRows()->save($row);
}
It will save the first row, but not the other rows.
Edit: Here is some of the markup, without the classes for bootstrap and validation. The row is being cloned with jQuery for each neccessary line for the document.
<tr class="item-row">
<td> class="form-control form-inline item-name" name="item[]">
</td>
<td>
<input type="text" name="description[]">
</td>
<td>
<input type="number" name="cost[]">
</td>
<td>
<input name="quantity[]">
</td>
<td>
<input type="number" name="itemTotal[]">
</td>
</tr>