I am trying to restrict usage of a certain endpoint to 10 times per day per user, and I can see how to do it for a certain number of times per minute. Please note that this is within a controller, not as middleware.
$executed = RateLimiter::attempt(
'user-send-test-' . Auth::user()->id,
$perDay = 10,
function () {
// some process
}
);
To use the rate limiter per day, use the fourth parameter of the method
attemp()which is the decay (how long an attempt need to be counted for) but I never tested it.If you still encounter issues with this example, I suggest you copy the
RateLimiterclass as it is very small and adapt its code.