Updated 5 February 2020
For Middleware
To assign middleware to all routes within a group, you can use the middleware method before defining the group. Middleware executes in the order as listed in the array:
1 2 3 4 5 |
Route::middleware(['first', 'second'])->group(function () { Route::get('/', function () { // Uses first & second Middleware }); Route::get('user/profile', function () { // Uses first & second Middleware }); }); |
Subdomain Routing
Route groups can also be used to handle subdomain routing. Subdomains may be assigned route parameters just like route URIs, allowing you to capture a portion of the subdomain for usage in your route or controller. The subdomain may be specified by calling the domain method before defining the group:
1 2 3 |
Route::domain('{account}.myapp.com')->group(function () { Route::get('user/{id}', function ($account, $id) { // }); }); |
Rate Limiting
Laravel includes a middleware to rate limit access to routes within your application. To get a start, assign the throttle middleware to a route or a group of routes. The throttle middleware accepts two parameters that determine the maximum number of requests that can be made in a given number of minutes. For example, let’s specify that an authenticated user may access the following group of routes 60 times per minute:
1 2 3 |
Route::middleware('auth:api', 'throttle:60,1')->group(function () { Route::get('/user', function () { // }); }); |
Hope it will be helpful for you. If you have any issue feel free to raise a ticket at https://bagisto.uvdesk.com/en/
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.