src/Managers/DocumentManager.php
/**
     * Convert multiple items to documents.
     * @param \iterable $items Items for which documents should be composed.
     * @return array Composed documents.
     * @throws InvalidArgumentException When items belong to different indices.
     */
Convert multiple items to documents.
@param \iterable $items Items for which documents should be composed.
@return array Composed documents.
@throws InvalidArgumentException When items belong to different indices.
Convert multiple items to documents . @param \ iterable $items Items for which documents should be composed . @return array Composed documents . @throws InvalidArgumentException When items belong to different indices .
protected function toDocuments($items): array
    {
        $indexName = null;
        foreach ($items as $item) {
            if (is_null($indexName)) {
                $indexName = $this->getIndexName($item);
            } else {
                $currentIndexName = $this->getIndexName($item);
                if ($indexName != $currentIndexName) {
                    throw new InvalidArgumentException(
                        'All items have to belong to same index.
	                    Found ' . $indexName . ' and ' . $currentIndexName
                    );
                }
            }
        }
        $wrappedDocuments = $this->fractal
            ->createData(new FractalCollection($items, $this->getTransformerByIndexName($indexName)))
            ->toArray();
        return $wrappedDocuments['data'];
    }
protected function toDocuments ( $ items ) : array { $ indexName = null ; foreach ( $ items as $ item ) { if ( is_null ( $ indexName ) ) { $ indexName = $ this -> getIndexName ( $ item ) ; } else { $ currentIndexName = $ this -> getIndexName ( $ item ) ; if ( $ indexName != $ currentIndexName ) { throw new InvalidArgumentException ( 'All items have to belong to same index.
	                    Found ' . $ indexName . ' and ' . $ currentIndexName ) ; } } } $ wrappedDocuments = $ this -> fractal -> createData ( new FractalCollection ( $ items , $ this -> getTransformerByIndexName ( $ indexName ) ) ) -> toArray ( ) ; return $ wrappedDocuments [ 'data' ] ; }
Convert multiple items to documents.
Convert multiple items to documents .
// All items should belong to the same index // The ArraySerializer causes the documents to be wrapped.