diff --git a/src/Traits/LocalizationKernelTrait.php b/src/Traits/LocalizationKernelTrait.php index c9cf5e0..ffb0e55 100644 --- a/src/Traits/LocalizationKernelTrait.php +++ b/src/Traits/LocalizationKernelTrait.php @@ -37,7 +37,7 @@ protected function dispatchToRouter() | ------------------------------------------------------------------------------------------------ */ /** - * Register middleware groups to router (since Laravel 5.2) + * Register middleware groups to router (since Laravel 5.2). */ protected function registerMiddlewareGroups() { @@ -49,12 +49,14 @@ protected function registerMiddlewareGroups() } /** - * Register middleware to router + * Register middleware to router. */ protected function registerMiddleware() { foreach ($this->routeMiddleware as $key => $middleware) { - $this->router->middleware($key, $middleware); + method_exists($this->router, 'aliasMiddleware') + ? $this->router->aliasMiddleware($key, $middleware) + : $this->router->middleware($key, $middleware);; } } }