Make a new Relationship instance.

@param  string $type
@param  \Vinelab\NeoEloquent\Eloquent\Model $startModel
@param  \Vinelab\NeoEloquent\Eloquent\Model $endModel
@param  array  $properties
@return \Everyman\Neo4j\Relationship
555797
protected function makeRelationship($type, $startModel, $endModel, $properties = array())
    {
        return $this->client
            ->makeRelationship()
            ->setType($this->type)
            ->setStartNode($this->start)
            ->setEndNode($this->end)
            ->setProperties($this->attributes);
    }
624991
public function joinRelations($relations, $type = 'inner')
    {
        if (is_null($this->joiner)) {
            $this->joiner = static::$joinerFactory->make($this);
        }

        if (!is_array($relations)) {
            list($relations, $type) = [func_get_args(), 'inner'];
        }

        foreach ($relations as $relation) {
            $this->joiner->join($relation, $type);
        }

        return $this;
    }
1368130
public function createRelationship(
        PositionInterface $position,
        bool $hasData,
        ?RelationshipDataInterface $data,
        bool $hasLinks,
        ?iterable $links,
        bool $hasMeta,
        $meta
    ): RelationshipInterface {
        return new class (
            $position,
            $hasData,
            $data,
            $hasLinks,
            $links,
            $hasMeta,
            $meta
        ) implements RelationshipInterface
        {
            /**
             * @var PositionInterface
             */
            private $position;

            /**
             * @var bool
             */
            private $hasData;

            /**
             * @var ?RelationshipDataInterface
             */
            private $data;

            /**
             * @var bool
             */
            private $hasLinks;

            /**
             * @var ?iterable
             */
            private $links;

            /**
             * @var bool
             */
            private $hasMeta;

            /**
             * @var mixed
             */
            private $meta;

            /**
             * @var bool
             */
            private $metaIsCallable;

            /**
             * @param PositionInterface              $position
             * @param bool                           $hasData
             * @param RelationshipDataInterface|null $data
             * @param bool                           $hasLinks
             * @param iterable|null                  $links
             * @param bool                           $hasMeta
             * @param mixed                          $meta
             */
            public function __construct(
                PositionInterface $position,
                bool $hasData,
                ?RelationshipDataInterface $data,
                bool $hasLinks,
                ?iterable $links,
                bool $hasMeta,
                $meta
            ) {
                \assert($position->getLevel() > ParserInterface::ROOT_LEVEL);
                \assert(empty($position->getPath()) === false);
                \assert(($hasData === false && $data === null) || ($hasData === true && $data !== null));
                \assert(($hasLinks === false && $links === null) || ($hasLinks === true && $links !== null));

                $this->position       = $position;
                $this->hasData        = $hasData;
                $this->data           = $data;
                $this->hasLinks       = $hasLinks;
                $this->links          = $links;
                $this->hasMeta        = $hasMeta;
                $this->meta           = $meta;
                $this->metaIsCallable = \is_callable($meta);
            }

            /**
             * @inheritdoc
             */
            public function getPosition(): PositionInterface
            {
                return $this->position;
            }

            /**
             * @inheritdoc
             */
            public function hasData(): bool
            {
                return $this->hasData;
            }

            /**
             * @inheritdoc
             */
            public function getData(): RelationshipDataInterface
            {
                \assert($this->hasData());

                return $this->data;
            }

            /**
             * @inheritdoc
             */
            public function hasLinks(): bool
            {
                return $this->hasLinks;
            }

            /**
             * @inheritdoc
             */
            public function getLinks(): iterable
            {
                \assert($this->hasLinks());

                return $this->links;
            }

            /**
             * @inheritdoc
             */
            public function hasMeta(): bool
            {
                return $this->hasMeta;
            }

            /**
             * @inheritdoc
             */
            public function getMeta()
            {
                \assert($this->hasMeta());

                if ($this->metaIsCallable === true) {
                    $this->meta           = \call_user_func($this->meta);
                    $this->metaIsCallable = false;
                }

                return $this->meta;
            }
        };
    }
220119
public static function create(?TypeCollection $types = null): self
    {
        $types = $types ?? TypeCollection::createDefault();

        $parser = new Parser();

        $factory = new RouteFactory($parser, $types);

        return new self($factory);
    }
227658
public function join($type, $conditions)
  {
    if ( is_null($this->join) ){
      $this->join = [];
    }
    $this->join[] = new Element(strtoupper($type) . ' JOIN', $conditions);
    return $this;
  }
112238
function(startNode, type, endNode, properties, callback) {
    if (typeof properties === 'function') {
      callback = properties;
      properties = null;
    }

    if (Array.isArray(startNode)) {
      var txn = this._safeBatch();
      var args = [ type, endNode, properties ];
      async.map(startNode, naan.ecurry(txn.rel.create, args, [1,2,3]), 
          function(err, rels) {
            if (!err && Array.isArray(endNode))
              return callback(err, _.flatten(rels));
            callback(err, rels);
          });
      return this._safeBatchCommit(txn);
    } else if (Array.isArray(endNode)) {
      var txn = this._safeBatch();
      var args = [ startNode, type, properties ];
      async.map(endNode, naan.ecurry(txn.rel.create, args, [0,1,3]), callback);
      return this._safeBatchCommit(txn);
    }
    
    var startNodeId = this._getId(startNode),
        endNodeId = this._getId(endNode);

    if (!this._isValidId(startNodeId) ||
        !this._isValidId(endNodeId)) {
      return callback(new Error("Invalid ID"));
    }

    var request = {
      to: this._location('node', endNodeId),
      type: type,
    };

    if (properties) {
      request['data'] = properties;
    }

    var endpoint = util.format('%s/relationships', this._nodeRoot(startNodeId));
    var op = this.operation(endpoint, 'POST', request);
    this.call(op, function(err, rel) {
      if (err) {
        callback(err);
      } else {
        callback(null, this._createRelationshipObject(rel));
      }
    });
  }
488670
private function makeSubItem($type, array $properties = [], Closure $callback = null)
    {
        $item = self::make(array_merge($properties, compact('type')), $callback);

        $this->addChild($item);

        return $item;
    }
599680
public function morphMany(
        $entity,
        string $related,
        string $name,
        string $type = null,
        string $id = null,
        string $localKey = null
    ): MorphMany {
        // Here we will gather up the morph type and ID for the relationship so that we
        // can properly query the intermediate table of a relation. Finally, we will
        // get the table and create the relationship instances for the developers.
        list($type, $id) = $this->getMorphs($name, $type, $id);

        $relatedMapper = Manager::getInstance()->mapper($related);

        $table = $relatedMapper->getEntityMap()->getTable();

        $localKey = $localKey ?: $this->getKeyName();

        // Add the relation to the definition in map
        list(, $caller) = debug_backtrace(false);
        $relation = $caller['function'];
        $this->relatedClasses[$relation] = $related;

        $this->addManyRelation($relation);
        $this->addForeignRelation($relation);

        return new MorphMany($relatedMapper, $entity, /*$table.'.'.*/$type, /*$table.'.'.*/$id, $localKey);
    }
461850
public static function newFromEloquentObject(EloquentModel $eloquentModel)
    {
        $rc = new ReflectionClass(static::class);
        $entity = $rc->newInstanceWithoutConstructor();

        // get model data
        $dict = [
            'mapping' => $eloquentModel->getMapping(),
            'attributes' => $eloquentModel->getAttributes(),
            'relations' => $eloquentModel->getRelations()
        ];

        // attributes
        foreach ($dict['mapping']['attributes'] as $attribute => $column) {
            $entity->{$attribute} = $dict['attributes'][$column];
        }

        // embeddeds
        foreach ($dict['mapping']['embeddeds'] as $name => $embedded) {
            $entity->{$name} = $embedded['class']::newFromEloquentObject($eloquentModel, $name);
        }

        // relations
        foreach ($dict['mapping']['relations'] as $name => $relation) {
            // set relation object
            if (! empty($dict['relations'][$name])) {
                $relationObject = $dict['relations'][$name]->toDatamapperObject();
            } elseif (in_array($relation['type'], $eloquentModel->manyRelations)) {
                $relationObject = new ProxyCollection;
            } else {
                $relationObject = new Proxy;
            }
            
            $entity->{$name} = $relationObject;
        }

        return $entity;
    }
1054152
public static function create($belongsTo, $type, $data, $attributes = [])
    {
        $obj = new Task();
        $obj->belongsTo = $belongsTo;
        $obj->type = $type;
        $obj->data = $data;
        $obj->additional = $attributes;
        $obj->save();
    }
724718
private function makeItem($type, $properties = [], Closure $callback = null)
    {
        $properties = array_merge($properties, [
            'type' => $type,
            'root' => true,
        ]);

        $item = MenuItem::make($properties, $callback);
        $this->addItem($item);

        return $item;
    }
96633
public function create(array $base, array $properties = array(), $type = self::TYPE_GENERAL_COUPON)
    {
        $key = strtolower($type);
        $card = array_merge(array('base_info' => $base), $properties);
        $params = array(
            'card' => array(
                'card_type' => $type,
                $key => $card,
            ),
        );

        $result = $this->http->jsonPost(self::API_CREATE, $params);

        return $result['card_id'];
    }
1043330
protected function createInstance($classes, $properties) {
        $first = array_shift($classes);
        $instance = $first->createInstanceWithProperties($properties);
        foreach ($classes as $class) {
            $instance = $this->getResource('');
            $instance->setType($class);
        }
        return $instance;
    }
597608
public function withProperties(array $properties): self
    {
        $query = $this;

        foreach ($properties as $property => $cypher) {
            $query = $query->withProperty($property, $cypher);
        }

        return $query;
    }
239844
public function initRelation()
    {
        // Turn models into nodes
        $this->start = $this->asNode($this->parent);
        $this->hyper = $this->asNode($this->related);
        $this->end   = $this->asNode($this->morph);

        // Not a unique relationship since it involves multiple models.
        $unique = false;

        // Setup left and right edges
        $this->left  = new EdgeOut($this->query, $this->parent, $this->related, $this->type, $this->attributes, $unique);
        $this->right = new EdgeOut($this->query, $this->related, $this->morph, $this->morphType, $this->attributes, $unique);
        // Set the morph type to the relationship so that we know who we're talking to.
        $this->right->morph_type = get_class($this->morph);
    }
1010452
public function create( $type, array $properties = [ ] ) {

		$type = (string) $type;

		if ( isset( $this->classes[ $type ] ) ) {
			$class = $this->classes[ $type ];

			return new $class( $properties );
		} else if ( class_exists( $type ) ) {
			$class = new $type( $properties );
			if ( $class instanceof FilterInterface ) {

				return $class;
			}
		}

		throw new Exception\InvalidArgumentException(
			sprintf(
				'The given class <code>%s</code> does not exists.',
				$type
			)
		);

	}
1331931
public function create($class, $property = null, $type = null, $linked = null)
    {
        return $this->executeClassOrPropertyCommand(
            'create', $class, $property, $type, $linked
        );
    }