How to assign multiple middleware to Laravel route ?

2019-12-10 00:16:45 Satyam Laravel

Laravel Multiple Middlewares on single Url

You can assign multiple middlewares to Laravel route by using middleware method.

Example

// Assign multiple multiple middlewares to Laravel to a specific route

Route::get('/', function () {
    //
})->middleware('firstMiddleware', 'secondMiddleware');

// Assign multiple multiple middlewares to Laravel to route groups

Route::group(['middleware' => ['firstMiddleware','secondMiddleware']], function () {
    //
});


This post is submitted by one of our members. You may submit a new post here.

Related Tricks