Answer the question
In order to leave comments, you need to log in
How to set a limit on the number of entries for an arbitrary category?
Good afternoon!
The initial data is standard: there is a model aNewModel with fields id, user_id, content and a controller aNewController. The controller has a method for creating a new record create.
There are two questions: 1) Where and how is it better to set quantitative restrictions on the creation of new records (for one user) - in the controller in the store method or use middleware, or there are other ways. What do you recommend?
There are about 10 such controllers.
2) Where and how to make a limit on the number of new records per unit of time (for example, per second)?
The question is related to the need to protect against automation programs and bots.
Answer the question
In order to leave comments, you need to log in
1. Probably immediately after or during the user rights check.
2. To limit the number of requests from the user per unit of time for a specific route, there is https://laravel.com/docs/routing#rate-limiting
or is it better to remake the logic on FormRequest and do checks in authorize ?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question