I have a users' table and another table for their respective plans.I have a form that displays the users and their plans. I want a HR officer to be able to enter his/remarks to all plans and save all by a single submit button. Please help on how to refactor this code.
public function submitHrRemarks(Request $request){
foreach ($plan_id = $request->plan_id as $key => $value) {
if ($plan_id[$key] != '') {
$hr_remarks = $request->hr_remarks[$key];
// dd($hr_remarks,$value);
$query = DB::table("weekly_plans")
->updateOrInsert(
[
'id' => $plan_id[$key], // pass your update id else empty
],
// $data =
[
'id' => $value,
'hr_remarks' => $hr_remarks,
]);
}
}
flash('You have successfully submitted the remarks!');
return back();
}