Angielski Uzet
Angielski Uzet

Reputation: 265

Is there something like action throttle in Laravel 5.4?

Searching on internet, in documentation, routes etc, using search box, and I can find only throttling for authentication.

I have create topics for some sections by users in my project and I need them to can do it only 5-10 per this action.

So my question is

Is in laravel something that I can use, any action-throttling, route-throttling, idk, something like this? If it is not then other best ways to apply this in newest Laravel for particular aciton?

Upvotes: 2

Views: 695

Answers (3)

Ahmad Mobaraki
Ahmad Mobaraki

Reputation: 8170

Starting from Laravel 5.2, you can use trottle middlware:

In kernel file:

protected $routeMiddleware = 
[
. 
.
'trottle' => Illuminate/Routing/Middleware/TrottleRequests
]

Use in routes:

Route::middleware('throttle:60,1')->group(function () {
    Route::get('/user', function () {

    });
});

Upvotes: 0

Rutvik Bhatt
Rutvik Bhatt

Reputation: 486

Throttling mostly implemented in API based application, but it is also feasible in web based apps.

If you are using API: Here is the boilerplate that implements API limits.

Git hub: https://github.com/iamrutvik/laravel-5.3-api-seed

API limit Doc: https://github.com/dingo/api/wiki/Rate-Limiting

If you are using web based App, you might want to look into this repo: https://github.com/GrahamCampbell/Laravel-Throttle

See if this helps you, let me know if it works.

Upvotes: 1

user8279057
user8279057

Reputation:

Throttling in laravel is mainly used for authentication purpose, like re-captcha and front end validation.

I have attached a link where you can learn more about it. http://miftyisbored.com/a-complete-tutorial-on-login-throttling-and-recaptha-with-laravel-5-3/

Hope this helps. Thanks!

Upvotes: 0

Related Questions