Laravel PHP Developer Question:
Download Job Interview Questions and Answers PDF
Explain me how to assign multiple middleware to Laravel route ?
Answer:
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 () {
//
});
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 () {
//
});
Download Laravel PHP Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Tell me how To Set Database Connection In Laravel? | What is Composer in Laravel PHP? |