Laravel Interview Questions And AnswersSubmit a Question

54. How to assign multiple middleware to Laravel route ?

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

Example
// Assign multiple multiple middleware to Laravel to specific route

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

// Assign multiple multiple middleware to Laravel to route groups

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

Leave a Reply

Your email address will not be published. Required fields are marked *