I am having problems with attaching a middleware to my existing routes.
Problem is with extra parameters, which cause syntax errors.
My current route:
Route::get('summary/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show']);
Adding the needed middleware is described in the package I am trying to use:
https://github.com/GrahamCampbell/Laravel-Throttle
I fail when I am trying to do this:
Route::get('add-to-cart/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show'])->middleware([GrahamCampbellThrottleHttpMiddlewareThrottleMiddleware:10,30]);
The middleware does not cause issues if I omit the :10,30
part.
TODO:
Attach the middleware with all the parameters.
2
Answers
Try with that two different ways:
OR
Here’s how you can properly attach the ThrottleMiddleware with parameters
use GrahamCampbellThrottleHttpMiddlewareThrottleMiddleware;
Route::get(‘summary/{topicid}/{issueid}’, [AppHttpControllersSummaryController::class, ‘show’])
->middleware([ThrottleMiddleware::class . ‘:10,30’]);