protected function fixLinks($result)
    {
        if (false === $this->replaceLinks) {
            return $result;
        }

        $isArray = false;
        $string = '';
        if (is_array($result)) {
            $string = json_encode($result, JSON_UNESCAPED_SLASHES);
            $isArray = true;
        } elseif (is_string($result)) {
            $string = $result;
        }

        $myUri = Environment::getURI();

        $allRws = Service::whereType('rws')->whereIsActive(1)->get()->all();
        if (!empty($allRws)) {
            /** @var Service $rws */
            foreach ($allRws as $rws) {
                $config = $rws->getConfigAttribute();
                $baseUrl = trim(array_get($config, 'base_url'), '/');
                $dfUrl = trim($myUri, '/') . '/api/v2/' . $rws->name;
                $string = str_replace($baseUrl, $dfUrl, $string);
            }
        }

        return ($isArray) ? json_decode($string, true) : $string;
    }