public function map($results, array $eagerLoads = [], $useCache = false) : Collection
    {
        $builder = $this->newResultBuilder(!$useCache);

        if ($results instanceof Collection) {
            // Get underlying collection array
            $results = $results->all();
        }

        if (!is_array($results)) {
            throw new InvalidArgumentException("Parameter 'results' should be an array or a collection.");
        }

        // First, we'll cast every single result to array
        $results = array_map(function ($item) {
            return (array) $item;
        }, $results);

        // Then, we'll pass the results to the Driver's provided transformer, so
        // any DB specific value can be casted before hydration
        $results = $this->adapter->fromDatabase($results);

        $entities = $builder->build($results, $eagerLoads);

        return $this->entityMap->newCollection($entities);
    }
public function map($results, array $eagerLoads = [], $useCache = false) : Collection
    {
        $builder = $this->newResultBuilder(!$useCache);

        if ($results instanceof Collection) {
            // Get underlying collection array
            $results = $results->all();
        }

        if (!is_array($results)) {
            throw new InvalidArgumentException("Parameter 'results' should be an array or a collection.");
        }

        // First, we'll cast every single result to array
        $results = array_map(function ($item) {
            return (array) $item;
        }, $results);

        // Then, we'll pass the results to the Driver's provided transformer, so
        // any DB specific value can be casted before hydration
        $results = $this->adapter->fromDatabase($results);

        $entities = $builder->build($results, $eagerLoads);

        return $this->entityMap->newCollection($entities);
    }
public function map ( $ results , array $ eagerLoads = [ ] , $ useCache = false ) : Collection { $ builder = $ this -> newResultBuilder ( ! $ useCache ) ; if ( $ results instanceof Collection ) { // Get underlying collection array $ results = $ results -> all ( ) ; } if ( ! is_array ( $ results ) ) { throw new InvalidArgumentException ( "Parameter 'results' should be an array or a collection." ) ; } // First, we'll cast every single result to array $ results = array_map ( function ( $ item ) { return ( array ) $ item ; } , $ results ) ; // Then, we'll pass the results to the Driver's provided transformer, so // any DB specific value can be casted before hydration $ results = $ this -> adapter -> fromDatabase ( $ results ) ; $ entities = $ builder -> build ( $ results , $ eagerLoads ) ; return $ this -> entityMap -> newCollection ( $ entities ) ; }
Map results to a Collection.

@param array|Collection $results
@param array            $eagerLoads
@param bool             $useCache

@return Collection
Map results to a Collection .