Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sidart's avatar
Level 12

Lock an action on the vuejs front end, for a given minute period.

Hello everyone,

I am building a small task like dashboard.

Technologies: Laravel, Vuejs, Vuex

The page gets two types of categories from the database: plates and foods for example, and creates two lists with every option displayed like a button.

A user will choose the plate first from the top list and match it with a food on the bottom list, and press the add button to save the action.

The requirement is that the type of food needs to be disabled for a period of time specified buy the admin like 3 minutes.

So once the user selects a food, that food can't be selected for 3 minutes, once the time is over the food option unlocks.

I can't figure out a good way to handle this situation that will not break with a page refresh, any ideas are welcome!

0 likes
6 replies
Sinnbeck's avatar

Have it send a request (poll) to the backend every 5 seconds, to check if it is allowed to show the food as available.

If you do it in the frontend alone, you allow the user to work around it (if they know what they are doing)

1 like
Sidart's avatar
Level 12

Of course the Backend will be the main spot for the decisions, eather with axios or websockets.

My main struggle is on how to save the records time. I though of when saving the record to have a column that sets the delete_after or something, and dispatch a job that will delete that record after that time.

Its obvious that i am confused on the part of how to determine the time on the database side.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Why not just set expire time in a table for specifically this (user, food and expiration) and check against it every time it polls. You can clear old entries every 10 minutes or so using a task (or if the poll find it is expired)

Sidart's avatar
Level 12

So basically set the expire_at to something like Carbon::now()->addMinutes(3); and then check if that time has passed on every poll?

Lastly, run a task that clears all records older that 10 minutes.

I think this is what you mean.

Sinnbeck's avatar

Yeah exactly. That is how I would set it up myself.

Sidart's avatar
Level 12

Alright, it feels like a good solution.

Thank you for your input and your time @sinnbeck

Please or to participate in this conversation.