php - Laravel One user running one piece of code at a time

one text

I have a laravel application that offers APIs to clients. I have a chunk of code that I want only one single user to access it at any given time. so if a user calls the API that contains the following code, and the user starts running the code block:

some code here

And then another user calls the same API and tries to run the code block, the second user should not be allowed to run the code block until the first user is finished with it. Does such feature exist in Laravel? Like mutex, but i'm not talking about threads, just more than one user calling the same API.

Source