R
R
root092018-11-11 17:39:39
Laravel
root09, 2018-11-11 17:39:39

How to make an action limit?

There is a controller, it has a method, how can you make a restriction on its execution so that the user can execute it no more than, for example, 5 minutes?
Is there any option other than how to create a table and store the date of the last call in it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2018-11-11
@root09

Laravel has a ready-made middleware for this - throttle . Plug it in and set it up the way you want.
In the route, add 'middleware' => 'throttle:1,5'1 - how many times, 5 - how many minutes timeout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question