private function getRelations(Repository $repository, array $relations = [])
    {
        // if we have relation array passed, ignore request input
        if (count($relations) === 0) {
            $relations = Input::get('with');

            if (!is_array($relations)) {
                $relations = $this->inputService->decode('with');
            }
        }

        $result = [];
        $repo_relations = $repository->relations();
        foreach ($relations as $key => $value) {
            if (in_array($key, $repo_relations)) {
                $result[] = $key;
            } elseif (in_array($value, $repo_relations)) {
                $result[] = $value;
            }
        }

        return $result;
    }