protected function setForeignConstraintFromArray(array $properties)
    {
        $foreignConstraint = $this->getForeignConstraintFromArray($properties);

        $this->setForeignConstraint($foreignConstraint);

        if ($this->hasForeignConstraint() && !$this->hasForeignRelation()) {
            $this->setForeignRelation($foreignConstraint->getForeignRelation());
        }

        return $this;
    }