My problem is that I am creating a shipper application. When two people receive the same order, both of their amounts will be deducted. How can I do this if only one person can receive orders at a time in Laravel?
$cacheKeyOrder = “accept_order_” . $request[‘order_id’] . “shipper” . $dm->id;
if (Cache::has($cacheKeyOrder)) {
Cache::forget($cacheKeyOrder);
return response()->json([
'errors' => [
['code' => 'order', 'message' => 'Đơn hàng đã được tài xế khác xác nhận trước !']
]
], 203);
} else {
Cache::put($cacheKeyOrder, true);
}
New contributor
Hoang Nam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.