D
D
Danil Sysoev2019-02-04 07:15:33
Laravel
Danil Sysoev, 2019-02-04 07:15:33

How to queue begintransaction?

Question on transactions:
There is a script which changes a cell. But the fact is that if, for example, I make a simultaneous request from two devices, then one request (which is the first one) is executed, and the second one is not. And it is necessary that both were executed, only in the order of the queue.
How to implement something like this. I did not find information on this issue, or maybe I just did not ask the right question.

DB::beginTransaction();

$balanceNow = Users::find(Auth::id());

if ($balanceNow < $request->sum) {
      return Response::json([
         "errors" => ["Ошибка"]
      ], 422);
}

$response = json_decode(Wallet::send($request->address, $request->sum));
//записи в базе
if ($response->desc == 'OK') {
   DB::commit();
}else{
   DB::rollBack();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2019-02-04
@Kostik_1993

So you need https://laravel.ru/docs/v5/queues queues, not transactions.
Transactions are needed when writing to the database, in your example you don’t understand why

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question