protected function resultsToModelsWithRelations($connection, ResultSet $results)
    {
        $models = [];

        if ($results->valid())
        {
            $grammar = $this->getQuery()->getGrammar();
            $columns = $results->getColumns();

            foreach ($results as $result)
            {
                $attributes = $this->getProperties($columns, $result);
                // Now that we have the attributes, we first check for mutations
                // and if exists, we will need to mutate the attributes accordingly.
                if ($this->shouldMutate($attributes))
                {
                    foreach ($attributes as $identifier => $values)
                    {
                        $cropped = $grammar->cropLabelIdentifier($identifier);

                        if (! isset($models[$cropped])) $models[$cropped] = [];

                        if(isset($this->mutations[$cropped]))
                        {
                            $mutationModel = $this->getMutationModel($cropped);
                            $model = $mutationModel->newFromBuilder($values);
                            $model->setConnection($mutationModel->getConnectionName());

                            $models[$cropped][] = $model;
                        }
                    }
                }
            }
        }

        return $models;
    }
protected function resultsToModelsWithRelations($connection, ResultSet $results)
    {
        $models = [];

        if ($results->valid())
        {
            $grammar = $this->getQuery()->getGrammar();
            $columns = $results->getColumns();

            foreach ($results as $result)
            {
                $attributes = $this->getProperties($columns, $result);
                // Now that we have the attributes, we first check for mutations
                // and if exists, we will need to mutate the attributes accordingly.
                if ($this->shouldMutate($attributes))
                {
                    foreach ($attributes as $identifier => $values)
                    {
                        $cropped = $grammar->cropLabelIdentifier($identifier);

                        if (! isset($models[$cropped])) $models[$cropped] = [];

                        if(isset($this->mutations[$cropped]))
                        {
                            $mutationModel = $this->getMutationModel($cropped);
                            $model = $mutationModel->newFromBuilder($values);
                            $model->setConnection($mutationModel->getConnectionName());

                            $models[$cropped][] = $model;
                        }
                    }
                }
            }
        }

        return $models;
    }
protected function resultsToModelsWithRelations ( $ connection , ResultSet $ results ) { $ models = [ ] ; if ( $ results -> valid ( ) ) { $ grammar = $ this -> getQuery ( ) -> getGrammar ( ) ; $ columns = $ results -> getColumns ( ) ; foreach ( $ results as $ result ) { $ attributes = $ this -> getProperties ( $ columns , $ result ) ; // Now that we have the attributes, we first check for mutations // and if exists, we will need to mutate the attributes accordingly. if ( $ this -> shouldMutate ( $ attributes ) ) { foreach ( $ attributes as $ identifier => $ values ) { $ cropped = $ grammar -> cropLabelIdentifier ( $ identifier ) ; if ( ! isset ( $ models [ $ cropped ] ) ) $ models [ $ cropped ] = [ ] ; if ( isset ( $ this -> mutations [ $ cropped ] ) ) { $ mutationModel = $ this -> getMutationModel ( $ cropped ) ; $ model = $ mutationModel -> newFromBuilder ( $ values ) ; $ model -> setConnection ( $ mutationModel -> getConnectionName ( ) ) ; $ models [ $ cropped ] [ ] = $ model ; } } } } } return $ models ; }
Turn Neo4j result set into the corresponding model with its relations

@param  string $connection
@param  \Everyman\Neo4j\Query\ResultSet $results
@return array
Turn Neo4j result set into the corresponding model with its relations