Controller:
public function UpdateAll(Request $request, $id)
{
$items = $request->input("item");
foreach ($items as $key => $value) {
DB::table('marketing_customer_profile_products')
->where('id', $value['id'])
->
update([
'local_price_pres' => $value["local_price_pres"],
'import_price_pres' => $value["import_price_pres"],
'updated_by' => Auth::user()->id
]);
} Session::flash('flash_message', 'Successfully updated this record');
Session::flash('flash_type', 'alert-success');
return redirect()->back();
}
View:
<form method="POST" action="{{ route('marCusProProductUpdateAll', $product->id) }}">
@csrf
<input type="hidden" name="customer_id" value="{{ $newdata->customer_id }}">
<input type="hidden" name="mcp_id" value="{{ $mcpData->id }}">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-bordered table-striped" id="customerProfileProducts">
<thead>
<tr>
<th>LP Pres</th>
<th>IP Pres</th>
</tr>
</thead>
<tbody>
@if (!empty($data))
<?php $count = count($data); ?>
@foreach ($data as $value)
<tr>
<td class="text-right"><input type="number" step="any" name="item[{{ $value->id }}] [local_price_pres]" class="form-control lpp" value="{{ $value->local_price_pres }}"></td>
<td class="text-right"><input type="number" step="any" name="item[{{ $value->id }}] [import_price_pres]" class="form-control ipp" value="{{ $value->import_price_pres }}"></td>
<tr>
</tbody>
</table>
<input type="submit" class="btn btn-success mx-auto d-block" value="Update All">
</form>