Вы можете выполнить любую логику, если захотите, расширив исходное промежуточное ПО ThrottleRequests
:
<?php
namespace App\Http\Middleware;
use Closure;
class ThrottleRequests extends \Illuminate\Routing\Middleware\ThrottleRequests
{
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 2)
{
$original = parent::handle($request, $next, $maxAttempts, $decayMinutes);
if ($this->limiter->tooManyAttempts($key, $maxAttempts, $decayMinutes)) {
// Do whatever you need to...
}
return $next($request);
}
}
Затем отредактируйте App \ Http \ Kernel.php , чтобы использовать пользовательское промежуточное ПО ThrottleRequests:
protected $routeMiddleware = [
'throttle' => \App\Http\Middleware\ThrottleRequests::class,
];