I am trying to update my table row in foreach loop, I have simplified it, but I am geting the same error over and over again.
$zaglavlje = App\Zagljavlje::where('broj_dokumenta','=',$request->zaglavljeId)->first();
$index = 0;
foreach(App\Stavke::where('zaglavlje_id', '=', $zaglavlje->id)->get() as $stavka) {
$stavkaPromjena = App\Stavke::where('zaglavlje_id','=',$zaglavlje->id)
->where('stavka_id','=',$stavka->stavka_id)->first();
$stavkaPromjena->kolicina = $request->kolicina[$index];
$stavkaPromjena->save();
$index++;
}
I have a POST request that gets values from an input tag
<input name="kolicina[]" type="number" max="{{$stavka->kolicina}}" min="1" value="{{ $stavka->kolicina }}">
The foreach loop has the same size as the array from POST I have checked it.
I am geting
"Illegal offset type in isset or empty"
error.
The type in my database of this column is "decimal".
What am I missing here ?