public function finalize()
    {
        foreach ($this->getGroups() as $group) {
            foreach ($group->getMiddleware() as $middleware) {
                array_unshift($this->middleware, $middleware);
            }
        }
        foreach ($this->getMiddleware() as $middleware) {
            $this->addMiddleware($middleware);
        }
    }