Я использую Laravel с адаптивной таблицей. каждая строка имеет уникальный набор данных вместе с одним полем, которое я хочу изменить sh. После изменения я хочу отправить его в базу данных с добавленными данными. Я немного усложнил это, потянув данные в исходную таблицу из двух sql таблиц, после чего их необходимо отправить в две таблицы в зависимости от того, внесены они или выплачены.
Это моя форма
<form name='verify' method='post'>
{{ csrf_field() }}
<table class="table table-bordered" id="dataTable" width="95%" cellspacing="0">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Paid Out</th>
<th>Paid In</th>
<th>Assign Property</th>
</tr>
</thead>
<tbody>
<tr>
@foreach ($tempupload as $bill)
@foreach ($select_properties as $props)
<td>{{$bill->BillDate}}</td>
<td>{{$bill->Description}}</td>
<td>{{$bill->PaidOut}}</td>
<td>{{$bill->PaidIn}}</td>
<td>
<select name='property[]' class='form-control'>
<option value='' disabled selected> Please Choose </option>
<option value='N/A'>Not aligned</option>
<option value='{{$props->uniqueid}}'>{{$props->prop_num.$props->name.', '.$props->street.', '.$props->postcode}}</option>
</select>
</td>
<input type='hidden' name='PaidOut[]' value='{{$bill->PaidOut}}' readonly>
<input type='hidden' name='PaidIn[]' value='{{$bill->PaidIn}}' readonly>
<input type='hidden' name='TempID[]' value='{{$bill->id}}' readonly>
<input type='hidden' name='propertymgr[]' value='{{$props->manager}}' readonly>
<input type='hidden' name='date[]' value='{{$bill->BillDate}}' readonly>
</tr>
@endforeach
@endforeach
</tbody>
<tr>
<td colspan='4'></td>
<td>
<input type='submit' value='Assign all values' name='submit' class='btn btn-success'></input>
</td>
</table>
</form>
Это мой бэкэнд
public function verify() {
if(Request::input('submit')) {
$TempID = Request::input('TempID');
$i = 0;
foreach($TempID as $value) {
$property = Request::input('property');
$PaidIn = Request::input('PaidIn');
$PaidOut = Request::input('PaidOut');
$propertymgr = Request::input('propertymgr');
$date = Request::input('paymentdate');
if ($property == '') {
// We don't want to do anything as the information might not have been submitted correctly.
} elseif ($property == 'N/A') {
// Define if it's a payment or junk, cause we don't need no headers.
if ($PaidOut == 'Paid Out') {
//If it's a header we just want to get rid of that.
DB::table('TempUpload')->where('BillDate','=', 'Date')->delete();
}
//Otherwise, it could just not be linked to a property. So, we need to separate In's and Out's
if ($PaidIn == '') {
//Assume its a Expense
DB::table('expenses')->insert(array(
'amount' => $PaidIn,
'property_id' => 'None', //No id required as it's not linked to a property
'property_manager' => 'None',
'date' => $date));
$i++;
} else {
//Assume its income
DB::table('income')->insert(array(
'amount' => $PaidIn,
'property_id' => 'None', //No id required as it's not linked to a property
'property_manager' => 'None',
'date' => $date));
$i++;
}
} else {
// Everything else can be put into the database. - Property linked
if ($PaidIn == '') {
//Assume its a Expense
DB::table('expenses')->insert(array(
'amount' => $PaidIn,
'property_id' => $property,
'property_manager' => $propertymgr,
'date' => $date));
$i++;
} else {
//Assume its income
DB::table('income')->insert(array(
'amount' => $PaidIn,
'property_id' => $property,
'property_manager' => $propertymgr,
'date' => $date));
$i++;
}
}
}
// We're done here.
return redirect('/admin/upload')->with('success', $i." Payments have been assigned their properties");
} else {
//it failed yo!
return redirect('/admin/upload')->with('error', "Something went wrong, no idea what to do.");
}
}
, и foreach продолжает отказывать Если у кого-то есть знания, чтобы помочь, я был бы очень признателен.