我已經創建多重輸入表單像下面的圖像,我要保存到數據庫中,當我使用dd()
這只是僅顯示在第二行數據的問題。Laravel插入多個輸入表單數據庫
我怎樣才能節省每一行數據庫?
這裏我laravel控制器
public function store(Request $request)
{
$input = Input::all();
$condition = $input['service_id'];
foreach ($condition as $key => $condition) {
$detailorder = new DetailOrder;
$detailorder->serivce_id = $input['service_id'][$key];
$detailorder->order_type = $input['order_type'][$key];
$detailorder->select_plan = $input['select_plan'][$key];
$detailorder->qty = $input['qty'][$key];
$detailorder->unit_price = $input['unit_price'][$key];
//$detailorder->mandays = $input['mandays'][$key];
$detailorder->note = $input['note'][$key];
}
dd($detailorder);
}
,在這裏我表腳本,我使用jQuery創建它
function getCorporateService(id){
// get data and parsing to column
$.get("{{ url('salesorder/service')}}/"+id, function(data){
console.log(id);
console.log(data);
$.each(data, function (index, element){
$br = "<tr id='item'>";
$br += "<td> <input class='input-small' type='text' id='order_identifier' name='order_identifier[]' readonly></td>";
$br += "<td><input class='input-small' type='text' id='service_name["+id+"]' name='service_name[]' value='"+element.service_name+"' readonly>"
+"<input class='input-small' type='hidden' id='service_id["+id+"]' name='service_id[]' value='"+element.id+"' readonly></td>";
$br += "<td><select id='order_type["+id+"]' name='order_type[]'> <option> - </option> <option value='add'>Add</option> <option value='change'>Change</option> <option value='cancel'>Cancel</option> </select></td>";
$br += "<td><input class='input-small' type='text' id='select_plan["+id+"]' name='select_plan[]'></td>";
$br += "<td><input class='input-mini' type='text' id='qty["+id+"]' name='qty[]' value='1' onChange='getTotalPrice("+id+")'></td>";
$br += "<td><input class='input-small' type='text' id='unit_price["+id+"]' name='unit_price[]' onChange='getTotalPrice("+id+")'></td>";
$br += "<td><input class='input-small' type='text' id='total_price["+id+"]' name='total_price[]' onChange='getTotalPrice("+id+")'></td>";
$br += "<td><textarea class='input-small' id='notes["+id+"]' name='note[]'></textarea></td>";
$br += "</tr>";
$(".corporatesvc").append($br);
});
});
}
謝謝。它現在的工作:) – rafitio