protected function isDuplicate($service, $resource, $value, $key = 'name')
    {
        $api = $service . '/' . $resource;
        switch ($api) {
            case 'system/role':
                return Role::where($key, $value)->exists();
            case 'system/service':
                return Service::where($key, $value)->exists();
            case 'system/app':
                return App::where($key, $value)->exists();
            case 'system/event_script':
            case 'system/custom':
            case 'user/custom':
            case $service . '/_schema':
                try {
                    $result = ServiceManager::handleRequest($service, Verbs::GET, $resource . '/' . $value);
                    if ($result->getStatusCode() === 404) {
                        return false;
                    }
                    if ($result->getStatusCode() >= 300) {
                        throw ResponseFactory::createExceptionFromResponse($result);
                    }

                    $result = $result->getContent();
                    if (is_string($result)) {
                        $result = ['value' => $result];
                    }
                    $result = array_get($result, config('df.resources_wrapper'), $result);

                    return (count($result) > 0) ? true : false;
                } catch (NotFoundException $e) {
                    return false;
                }
            default:
                try {
                    $result = ServiceManager::handleRequest($service, Verbs::GET, $resource,
                        ['filter' => "$key = $value"]);
                    if ($result->getStatusCode() === 404) {
                        return false;
                    }
                    if ($result->getStatusCode() >= 300) {
                        throw ResponseFactory::createExceptionFromResponse($result);
                    }

                    $result = $result->getContent();
                    if (is_string($result)) {
                        $result = ['value' => $result];
                    }
                    $result = array_get($result, config('df.resources_wrapper'), $result);

                    return (count($result) > 0) ? true : false;
                } catch (NotFoundException $e) {
                    return false;
                }
        }
    }