I am using updateOrCreate function for, when branchid, productid, batch_no is same update stock record or when these fields have different values create new stock record. some times duplicate stock record created. How to avoid It.
Stocks::updateOrCreate(
['branch_id' => $event->branch_id, 'product_id' => $event->product_id, 'batch_no' => $event->batch_no],
['manufacture_date' => $event->manufacture_date, 'expire_date' => $event->expire_date, 'current_stock' => $current_Stock, 'price' => $event->price]
);