Model locking and blocking #52725
Unanswered
RedmarBakker
asked this question in
Ideas
Replies: 1 comment 5 replies
-
What will lock and block do on a loaded model that exist already? That model exists in memory and php is not an async language so the model will not be altered by "another thread". |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I would like to suggest to add locking and blocking functionality to already loaded models. Laravel does have a
lockForUpdate
option when you query the model, but there is no option for models that are already queried.Scenario
For example when using Laravel Actions, I would like to have the ability to lock an already loaded model while doing an action.
ApproveOrder
example:Or, block:
Code
This would then be the underlaying logic, where the
lock
function is equivalent torefresh
but then withlockForUpdate
included in the query. Optionally,lock
could be modified so that it returns itself.I implemented this myself for my own projects. Would love to hear your thoughts.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions