Limit
class Limit (View source)
Properties
mixed|string | $key | The rate limit signature key. | |
int | $maxAttempts | The maximum number of attempts allowed within the given number of minutes. | |
int | $decayMinutes | The number of minutes until the rate limit is reset. | |
callable | $responseCallback | The response generator callback. |
Methods
void | __construct(mixed|string $key = '', int $maxAttempts = 60, int $decayMinutes = 1) Create a new limit instance. | |
static Limit | perMinute(int $maxAttempts) Create a new rate limit. | |
static Limit | perHour(int $maxAttempts, int $decayHours = 1) Create a new rate limit using hours as decay time. | |
static Limit | perDay(int $maxAttempts, int $decayDays = 1) Create a new rate limit using days as decay time. | |
static Limit | none() Create a new unlimited rate limit. | |
$this | by(string $key) Set the key of the rate limit. | |
$this | response(callable $callback) Set the callback that should generate the response when the limit is exceeded. |
Details
void __construct(mixed|string $key = '', int $maxAttempts = 60, int $decayMinutes = 1)
Create a new limit instance.
static Limit perMinute(int $maxAttempts)
Create a new rate limit.
static Limit perHour(int $maxAttempts, int $decayHours = 1)
Create a new rate limit using hours as decay time.
static Limit perDay(int $maxAttempts, int $decayDays = 1)
Create a new rate limit using days as decay time.
static Limit none()
Create a new unlimited rate limit.
$this by(string $key)
Set the key of the rate limit.
$this response(callable $callback)
Set the callback that should generate the response when the limit is exceeded.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Cache/RateLimiting/Limit.html