protected function setForeignRelationFromArray(array $properties)
    {
        if (Helpers::isKeyExists($properties, 'is-foreign-relation') && !$properties['is-foreign-relation']) {
            return $this;
        }

        $relation = ForeignRelationship::predict($this->name, Helpers::getModelsPath());

        if (Helpers::isKeyExists($properties, 'foreign-relation')) {
            $relation = ForeignRelationship::get((array) $properties['foreign-relation']);

            if (!is_null($relation)) {
                $this->setOnStore($properties);
                $this->setOnUpdate($properties);
            }

        } else if (Helpers::isKeyExists($properties, 'foreign-constraint')) {
            $constraint = $this->getForeignConstraintFromArray((array) $properties);

            if (!is_null($constraint)) {
                $relation = $constraint->getForeignRelation();
            }
        }

        $this->setForeignRelation($relation);

        return $this;
    }
protected function setForeignRelationFromArray(array $properties)
    {
        if (Helpers::isKeyExists($properties, 'is-foreign-relation') && !$properties['is-foreign-relation']) {
            return $this;
        }

        $relation = ForeignRelationship::predict($this->name, Helpers::getModelsPath());

        if (Helpers::isKeyExists($properties, 'foreign-relation')) {
            $relation = ForeignRelationship::get((array) $properties['foreign-relation']);

            if (!is_null($relation)) {
                $this->setOnStore($properties);
                $this->setOnUpdate($properties);
            }

        } else if (Helpers::isKeyExists($properties, 'foreign-constraint')) {
            $constraint = $this->getForeignConstraintFromArray((array) $properties);

            if (!is_null($constraint)) {
                $relation = $constraint->getForeignRelation();
            }
        }

        $this->setForeignRelation($relation);

        return $this;
    }
protected function setForeignRelationFromArray ( array $ properties ) { if ( Helpers :: isKeyExists ( $ properties , 'is-foreign-relation' ) && ! $ properties [ 'is-foreign-relation' ] ) { return $ this ; } $ relation = ForeignRelationship :: predict ( $ this -> name , Helpers :: getModelsPath ( ) ) ; if ( Helpers :: isKeyExists ( $ properties , 'foreign-relation' ) ) { $ relation = ForeignRelationship :: get ( ( array ) $ properties [ 'foreign-relation' ] ) ; if ( ! is_null ( $ relation ) ) { $ this -> setOnStore ( $ properties ) ; $ this -> setOnUpdate ( $ properties ) ; } } else if ( Helpers :: isKeyExists ( $ properties , 'foreign-constraint' ) ) { $ constraint = $ this -> getForeignConstraintFromArray ( ( array ) $ properties ) ; if ( ! is_null ( $ constraint ) ) { $ relation = $ constraint -> getForeignRelation ( ) ; } } $ this -> setForeignRelation ( $ relation ) ; return $ this ; }
Sets the foreign relations for a given field

@param array $properties

@return $this
Sets the foreign relations for a given field