I suggest using some dd in there to help troubleshoot.
Also maybe toSql().
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
protected function updateFulfillment(array $fulfillments): void
{
foreach ($fulfillments as $fulfillment) {
$fulfillmentRecord = Fulfillment::where('line_item_code', $fulfillment['line_item_code'])
->where('fulfillment_code', $fulfillment['fulfillment_code'])->first();
if ($fulfillmentRecord) {
$fulfillmentRecord->update([
'refunded' => true,
'returned_quantity' => $fulfillment['quantity']
]);
}
}
//what is the difference between the above and this one below query?
// The above query update two records and this below query updates a single record
foreach ($fulfillments as $fulfillment) {
Fulfillment::where('line_item_code', $fulfillment['line_item_code'])
->where('fulfillment_code', $fulfillment['fulfillment_code'])
->update([
'refunded' => true,
'returned_quantity' => $fulfillment['quantity']
]);
}
}
Please or to participate in this conversation.