laravel add multiple middleware to route code example

Example 1: multiple middleware laravel

Route::group(['middleware' => ['auth', 'web']], function() {
  // uses 'auth' middleware plus all middleware from $middlewareGroups['web']
  Route::resource('blog','BlogController'); //Make a CRUD controller
});

Example 2: laravel route multiple middleware

Route::get('/', function () {
//
})->middleware('first', 'second');

Example 3: laravel route multiple middleware

Route::group(['middleware' => ['auth', 'web']], function() {
  // uses 'auth' middleware plus all middleware from $middlewareGroups['web']
  Route::resource('blog','BlogController'); //Make a CRUD controller
});

Tags:

Php Example