Laravel update multiple fields of a model with a form

A Form with a submit with following given values:

startID: 5
lastID: 10


public function formUpdatePost(Request $request) {
$startid = $request->input('startID'); 
$endid = $request->input('lastID');
$ids = Products::whereBetween('id', [$startid, $endid])
->update(['price' => $newprice, 'tax' => $newtax]);

get the range of given ID’s in an array and update the fields with the new values by sending the form to database.

Featured Image:

Leave a Comment