protected function hasShouldRouteGroup($request): bool
    {
        if (!config('cors.laravel.route-group-mode')) {
            return true;
        }

        $shouldClsssName = ShouldGroup::class;
        $shouldAlias = collect(Route::getMiddleware())->flip()->get($shouldClsssName, $shouldClsssName);
        $route = collect(Route::getRoutes()->get())->first(function ($route) use ($request) {
            return $route->matches($request, false);
        });
        if (!$route) {
            return false;
        }
        $gatherMiddleware = $route->gatherMiddleware();

        if (in_array($shouldClsssName, $gatherMiddleware) || in_array($shouldAlias, $gatherMiddleware)) {
            return true;
        }

        $middlewareGroups = collect(Route::getMiddlewareGroups())->filter(function ($group) use ($shouldClsssName, $shouldAlias) {
            return in_array($shouldAlias, $group) || in_array($shouldClsssName, $group);
        })->keys();

        return $middlewareGroups->filter(function ($value) use ($gatherMiddleware) {
            return in_array($value, $gatherMiddleware);
        })->isNotEmpty();
    }