Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Throttle overwrite in second

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

like image 973
ostrichegret Avatar asked Dec 22 '25 23:12

ostrichegret


2 Answers

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 = ???

like image 60
Henry Bui Avatar answered Dec 24 '25 17:12

Henry Bui


With this issue, you can use throttle in seconds.

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

like image 21
francisco Avatar answered Dec 24 '25 15:12

francisco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!