Preventing Race Conditions Using Database Transactions (Laravel)

Laravel supports "pessimistic locking". For more information about that refer to the Laravel documentation on pessimistic locking.


Transactions are used when you are executing queries and wish to have a mechanism to reverse the resulting modifications if there is a possibility of error during their execution.

Where as what you are looking is Internal Locking Methods, where every request to the database is put in queue and is processed only when the previous is processed.

I don't know whether this features comes out of the box from laravel ORM but it could be easily implemented from classic sql queries.

Check out this link, to understand how the entire mechanism works, I believe what you are looking for is Row Level Locking.

Locking Methods