So after the form is posted I need to update only the object which has the checkbox selected.
The way I am trying to do that is searching for the value of checkbox in the passesPrinted array and return the key so I can just loop through and save the values.
I don't know if I understand what you are trying to do exactly, but I think it's along these lines:
$passes = Pass:whereIn('id', $request->passesPrinted)->get()->keyBy('id');
foreach($request->passesPrinted as $key => $id) {
// Pass $id has been checked
// you can also get it's 'serial' by: $request->serials[$key]
// $passes[$id] holds the Pass Object for this $id
$passes[$id]->update(['field' => 'new value']);
}
It get's all passes from the DB having an id that was within the checked checkboxes.
Then it loops over all passesPrinted id's and for each you can update it.
I come across an issue basically the checkbox key is different to the key of the serials array so I am saving the wrong serial to the wrong pass if that makes sense.
it will only work if i select every single checkbox so the keys match. Let says if I only select the second checkbox in the list it wont start [1] it will start form [0] again so I need it to match the key in the serial etc..
Then in your controller, $key will be the same as $id, and $key will always align between $request->passessPrinted and $request->serials
$passes = Pass:whereIn('id', $request->passesPrinted)->get()->keyBy('id');
foreach($request->passesPrinted as $key => $id) {
// Pass $id has been checked
// you can also get it's 'serial' by: $request->serials[$key]
// $passes[$id] holds the Pass Object for this $id
$passes[$id]->update(['field' => 'new value']);
}