Laravel Throttle overwrite in second

3k views Asked by At

How to use laravel throttle in second instead of in minute? I want to use this for chat app, and i think limiting it to second will be better.

and i tried to overwrite the laravel middleWareGroup throttle with this

Route::get("/v0/chat/get/{room}","chatController@chat_get")->middleware('throttle:120,1');

but the ->middleware() overwrite failed. Thanks

2

There are 2 answers

3
Henry Bui On

You must see ThrottlesLogin.php, at lockoutTime method to understand about lockoutTime.

protected function lockoutTime()
{
    return property_exists($this, 'lockoutTime') ? $this->lockoutTime : 60;
}

If you want to custom lockoutTime, init it in your controller $lockoutTime = ???

0
francisco On

With this issue, you can use throttle in seconds.

Now it is possible to use float for seconds, like 0.5 = 30 seconds.