Complete the code to register a middleware in the HTTP kernel.
protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class,
[1]
];The TrimStrings middleware is commonly registered globally in the $middleware array in app/Http/Kernel.php.
Complete the code to assign middleware to a route group in the kernel.
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
[1],
\App\Http\Middleware\ShareErrorsFromSession::class,
],
];The VerifyCsrfToken middleware is part of the web middleware group to protect against CSRF attacks.
Fix the error in registering a route middleware alias.
protected $routeMiddleware = [
'auth' => [1],
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
];::class suffix.Middleware classes must be referenced with the full namespace and ::class suffix to register correctly.
Fill both blanks to register a custom middleware alias and add it to the 'api' group.
protected $routeMiddleware = [
'checkAge' => [1],
];
protected $middlewareGroups = [
'api' => [
'throttle:60,1',
[2],
],
];The custom middleware class CheckAge is registered with the alias 'checkAge'. This alias is then added to the 'api' middleware group.
Fill all three blanks to register a middleware alias, add it to a group, and apply it to a route.
protected $routeMiddleware = [
[1] => \App\Http\Middleware\LogAccess::class,
];
protected $middlewareGroups = [
'web' => [
[2],
],
];
Route::middleware('[3]')->group(function () {
Route::get('/dashboard', function () {
return view('dashboard');
});
});The middleware alias 'log.access' is registered, added to the 'web' group, and applied to the route group to log access on those routes.