/** * Turn Neo4j result set into the corresponding model * @param string $connection * @param \Everyman\Neo4j\Query\ResultSet $results * @return array */ protected function resultsToModels($connection, ResultSet $results) { $models = []; if ($results->valid()) { $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)) { $models[] = $this->mutateToOrigin($result, $attributes); } else { $model = $this->model->newFromBuilder($attributes); $model->setConnection($connection); $models[] = $model; } } } return $models; }
public function valid() { return $this->resultSet->valid(); }
/** * @return int */ public function getResultCount() { return $this->result->count(); }
/** * Turn Neo4j result set into the corresponding model with its relations * * @param string $connection * @param \Everyman\Neo4j\Query\ResultSet $results * @return array */ 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; }