I was trying to update my table but I couldn't make it work.. I always end up with the error:
Invalid argument supplied for foreach()
Here is my Controller:
public function show_score($id)
{
$scores = Score::with(['lead','subject'])->where(['subject_id'=>$id])->get();
return view('markbook.show_score',compact('scores'));
}
public function update_score(Request $request)
{
$id = $request->input('id');
$scores = Score::find($id);
foreach ($scores as $datas) {
$datas->jan_ap=$request->input('jan_ap');
$datas->jan_hm=$request->input('jan_hm');
$datas->save();
}
}
route:
Route::get('markbook/scores/{id}', 'MarkbookController@show_score' );
Route::post('markbook/scores', 'MarkbookController@update_score');
Here is my table I'm trying to loop the updated score:

Score::find($id);finds one item/row, what are you trying to loop over here?