What if user call two requests, which checks user balance then perform operation on balance. Can it cause any problems? For example those two codes:
$user = User::find(1);
if($user['balance']>250) {
// Here for example long loop
$user->update([
'balance' => DB:raw('balance - 100')
]);
}
And second script doing similiar thing. Can be situation like: in first request if statement is passed , then long loop is executed, and in same time second request runing which has if checking balance and this if executes before $user->update() is excuted in first request, so can user pass if statement when he does not have balance?