Make a new Relationship instance.

@param  string $type
@param  \Sgpatil\Orientdb\Eloquent\Model $startModel
@param  \Sgpatil\Orientdb\Eloquent\Model $endModel
@param  array  $properties
@return \\Orientdb\Relationship
548361
protected function makeRelationship($type, $startModel, $endModel, $properties = array())
    {
        return $this->client
            ->makeRelationship()
            ->setType($type)
            ->setStartNode($startModel)
            ->setEndNode($endModel)
            ->setProperties($properties);
    }
777667
protected function instantiateTransformerModel(string $type)
    {
        try {
            // try Eloquent model factory
            return factory($type)->make();
        } catch (\Exception $e) {
            $instance = new $type;
            if ($instance instanceof \Illuminate\Database\Eloquent\Model) {
                try {
                    // we can't use a factory but can try to get one from the database
                    $firstInstance = $type::first();
                    if ($firstInstance) {
                        return $firstInstance;
                    }
                } catch (\Exception $e) {
                    // okay, we'll stick with `new`
                }
            }
        }

        return $instance;
    }
502955
protected function matchToMorphParents($type, array $results)
    {
        foreach ($results as $result) {
            if (isset($this->dictionary[$type][$result->getKey()])) {
                foreach ($this->dictionary[$type][$result->getKey()] as $model) {
                    $model->setRelation($this->relation, $result);
                }
            }
        }
    }
316677
public function createProperty($name, $type = NULL, $default = self::UNDEFINED, $modifiers = GProperty::MODIFIER_PROTECTED) {
    $gProperty = GProperty::create($name, $type, $default,  $modifiers);
    
    $this->addProperty($gProperty);
    return $gProperty;
  }
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);
    }
24785
public static function create(
        Annotation $annotation, Entity $entity, $property)
    {
        $parameters = $annotation->getParameters();
        unset ($parameters['_raw']);

        $related = $annotation->getValue();
        if (!class_exists($related)) {
            $parentClass = $entity->getClassName();
            throw new InvalidArgumentException(
                "Unknown class defined in {$parentClass}::_{$property}. ".
                "Class {$related} does not exists."
            );
        }

        /** @var BelongsTo $relation */
        $relation = new static($parameters);
        $relation->setEntity($entity)->setPropertyName($property);

        $relation->setRelatedEntity($related);
        return $relation;
    }
1282009
final public function create(array $properties = array())
    {
        $context = $this->getContext();
        $context->entity = $properties;

        if ($this->invokeCommand('before.create', $context) !== false)
        {
            $context->entity = $this->_actionCreate($context);
            $this->invokeCommand('after.create', $context);
        }

        $this->_entity = KObjectConfig::unbox($context->entity);

        return $this->_entity;
    }
228052
public function getModels($properties = array('*'))
    {
        // First, we will simply get the raw results from the query builders which we
        // can use to populate an array with Eloquent models. We will pass columns
        // that should be selected as well, which are typically just everything.
        $results = $this->query->get($properties);

        // Once we have the results, we can spin through them and instantiate a fresh
        // model instance for each records we retrieved from the database. We will
        // also set the proper connection name for the model after we create it.
        return $this->resultsToModels($this->model->getConnectionName(), $results, $properties);
    }
656563
public static function initRelations($model, $propertyName)
    {
        $className = BeanFactory::getObjectClass($model);
        $annotation = AnnotationManager::getPropertyAnnotations($className, $propertyName, RelationBase::class)[0] ?? null;
        if(null !== $annotation)
        {
            if($annotation instanceof \Imi\Model\Annotation\Relation\OneToOne)
            {
                $model->$propertyName = (ClassObject::parseSameLevelClassName($annotation->model, $className) . '::newInstance')();
            }
            else if($annotation instanceof \Imi\Model\Annotation\Relation\OneToMany)
            {
                $model->$propertyName = new ArrayList(ClassObject::parseSameLevelClassName($annotation->model, $className));
            }
            else if($annotation instanceof \Imi\Model\Annotation\Relation\ManyToMany)
            {
                $model->$propertyName = new ArrayList(ClassObject::parseSameLevelClassName($annotation->middle, $className));
            }
            else if($annotation instanceof \Imi\Model\Annotation\Relation\PolymorphicOneToOne)
            {
                $model->$propertyName = (ClassObject::parseSameLevelClassName($annotation->model, $className) . '::newInstance')();
            }
            else if($annotation instanceof \Imi\Model\Annotation\Relation\PolymorphicOneToMany)
            {
                $model->$propertyName = new ArrayList(ClassObject::parseSameLevelClassName($annotation->model, $className));
            }
            else if($annotation instanceof \Imi\Model\Annotation\Relation\PolymorphicManyToMany)
            {
                $model->$propertyName = new ArrayList(ClassObject::parseSameLevelClassName($annotation->middle, $className));
            }
            else
            {
                return;
            }
        }
    }
175498
public function first(Model $parentModel, Model $relatedModel, $type, $direction = 'any')
    {
        // First we get the first relationship instance between the two models
        // absed on the given direction.
        $relation = $this->firstRelation($parentModel, $relatedModel, $type, $direction);

        // Let's stop here if there is no relationship between them.
        if (is_null($relation)) return null;

        // Now we can return the determined edge out of the relation and direction.
        return $this->edgeFromRelationWithDirection($relation, $parentModel, $relatedModel, $direction);
    }
631584
public static function createObject($type, array $params = [])
    {
        if (is_callable($type, true)) {
            return call_user_func($type, $params);
        }

        if (is_string($type) && class_exists($type)) {
            $object = new $type();
        } elseif (is_array($type) && isset($type['class'])) {
            $class = $type['class'];
            unset($type['class']);
            $reflection = new \ReflectionClass($class);
            $object = $reflection->newInstanceArgs($params);
        }

        if (!empty($object) && is_array($type)) {
            foreach ($type as $property => $value) {
                $object->$property = $value;
            }
            return $object;
        }

        throw new \Exception("Unsupported configuration type: " . gettype($type));
    }
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'];
    }
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
			)
		);

	}
985055
public function newFromBuilder($attributes = [], $connection = null)
    {
        $attributes = (array) $attributes;

        if (! empty($attributes['type'])
            && isset(static::$models[$attributes['type']])
            && class_exists($class = static::$models[$attributes['type']])
        ) {
            /** @var Post $instance */
            $instance = new $class;
            $instance->exists = true;
            $instance->setRawAttributes($attributes, true);
            $instance->setConnection($connection ?: $this->connection);

            return $instance;
        }

        return parent::newFromBuilder($attributes, $connection);
    }
1256560
private void createRelationshipType(CmsRelationType relType) {

        // relationship types
        RelationshipTypeDefinitionImpl relationshipType = new RelationshipTypeDefinitionImpl();
        relationshipType.setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
        relationshipType.setParentTypeId(RELATIONSHIP_TYPE_ID);
        relationshipType.setIsControllableAcl(Boolean.FALSE);
        relationshipType.setIsControllablePolicy(Boolean.FALSE);
        relationshipType.setIsCreatable(Boolean.valueOf(!relType.isDefinedInContent()));
        relationshipType.setDescription(relType.getName());
        relationshipType.setDisplayName(relType.getName());
        relationshipType.setIsFileable(Boolean.FALSE);
        relationshipType.setIsIncludedInSupertypeQuery(Boolean.TRUE);
        relationshipType.setLocalName(relType.getName());
        relationshipType.setLocalNamespace(NAMESPACE);
        relationshipType.setIsQueryable(Boolean.FALSE);
        String id = "opencms:" + relType.getName().toUpperCase();
        relationshipType.setQueryName(id);
        relationshipType.setId(id);
        List<String> typeList = new ArrayList<String>();
        typeList.add("cmis:document");
        typeList.add("cmis:folder");
        relationshipType.setAllowedSourceTypes(typeList);
        relationshipType.setAllowedTargetTypes(typeList);
        addType(relationshipType);
    }
683464
public function newInstance($attributes = [], $exists = false): Model{
        /** @var Model $model */
        $model = parent::newInstance($attributes, $exists);
        $model->applyTypeSettings();
        return $model;
    }
751053
public function createInstanceWithProperties( core_kernel_classes_Class $type, $properties)
    {
        $returnValue = null;

        if (isset($properties[OntologyRdf::RDF_TYPE])) {
            throw new core_kernel_persistence_Exception('Additional types in createInstanceWithProperties not permited');
        }
        
        $properties[OntologyRdf::RDF_TYPE] = $type;
		$returnValue = new core_kernel_classes_Resource(common_Utils::getNewUri(), __METHOD__);
		$returnValue->setPropertiesValues($properties);
        
        return $returnValue;
    }