private function makeDocumentFromCollection(
        ResourceManager $resourceManager,
        string $resource,
        $result,
        Parameters $parameters,
        ApiRequestHandler $handler
    )
    {
        $document = new Document();
        $serializer = $resourceManager->resolveSerializer($resource);
        if ($handler instanceof ModifiesSerializer) {
            $serializer = $handler->modify($serializer);
        }
        $collection = new Collection($result, $serializer);
        if ($handler instanceof HasElementIncludes) {
            $handler->includes($collection);
        }

        $this->assignAndResolveIncludes($resourceManager, $resource, $collection, $parameters);
        $document->setData($collection);

        if ($handler instanceof HasDocumentMeta) {
            $handler->meta($document);
        }

        if (config('json-api.response.resources.links.self', false)) {
            $document->addLink('self', apiRoute($resource, null, request()->route('version')));
        }

        return $document;
    }