<form method="post" action="{{ route('postData') }}"> // assume you allready define the route
@csrf
// your other input field here
@foreach ($students as $student)
<input type="text" value="{{$student->name}}" id="" class="form-control">
<input type="hidden" name="student_id[]" value="{{$student->id}}" id="" class="form-control">
<input type="text" name="nominal[]" id="" class="form-control">
@endforeach
<button type="submit">Submit</button>
</form>
in controller
public function postData(Request $request)
{
// your other validation here
$studentIds = $request->input('student_id');
$nominals = $request->input('nominal');
// loop through the submitted data and update the records
foreach ($studentIds as $key => $studentId) {
$student = new YourTargetModel(); // replace model with your real model
$student->student_id = $studentId;
$student->nominal = $nominals[$key];
$student->save();
}
return redirect()->route('yourRoute')->with('success', 'Success');
}
public function postData(Request $request)
{
// your other validation here
$studentIds = $request->input('student_id');
$nominals = $request->input('nominal');
// loop through the submitted data and update the records
foreach ($studentIds as $key => $studentId) {
$student = new YourTargetModel(); // replace model with your real model
$student->student_id = $studentId;
$student->nominal = $nominals[$key];
$student->save();
}
return redirect()->route('yourRoute')->with('success', 'Success');
}
just add and customize the code as you need. if you have field name month_id in database make sure you have add the field in your form and in your controller add the
foreach ($studentIds as $key => $studentId) {
$student = new YourTargetModel(); // replace model with your real model
$student->monthId = $monthId;
$student->student_id = $studentId;
$student->nominal = $nominals[$key];
$student->save();
}