Adds foreign key constraint to a given properties.

@param string $properties
@param array $constraints

@return $this
190049
protected function addForeignConstraints(&$properties, array $constraints)
    {
        foreach ($constraints as $constraint) {
            $this->addForeignConstraint($properties, $constraint)
                ->addReferencesConstraint($properties, $constraint)
                ->addOnConstraint($properties, $constraint)
                ->addOnDeleteConstraint($properties, $constraint)
                ->addOnUpdateConstraint($properties, $constraint)
                ->addFieldPropertyClousure($properties);
        }

        return $this;
    }
664278
public function initAnnotation(array $properties) {
		if (isset ( $properties [0] )) {
			$this->type = $properties [0];
			unset ( $properties [0] );
			if (isset ( $properties [1] )) {
				if (! is_array ( $properties [1] )) {
					$this->constraints = [ "ref" => $properties [1] ];
				} else {
					$this->constraints = $properties [1];
				}
				unset ( $properties [1] );
			}
		} else {
			throw new \Exception ( 'Validator annotation must have a type' );
		}
		parent::initAnnotation ( $properties );
		if (! isset ( ValidatorsManager::$validatorTypes [$this->type] )) {
			throw new \Exception ( 'This type of annotation does not exists : ' . $this->type );
		}
	}
1366817
public function withProperties(array $properties): self
    {
        $map = $this->properties;

        foreach ($properties as $key => $value) {
            $map = $map->put($key, $value);
        }

        return new self(
            $this->object,
            $map,
            $this->injectionStrategy,
            $this->extractionStrategy
        );
    }
290727
protected function getForeignConstraintFromArray(array $properties)
    {
        if ($this->containsForeignConstraint($properties)) {
            return ForeignConstraint::fromArray($properties['foreign-constraint'], $properties['name']);
        }

        return null;
    }
612895
protected function setPlaceholder(array $properties)
    {
        $labels = $this->getPlaceholderFromArray($properties);

        foreach ($labels as $label) {
            $this->addPlaceholder($label->text, $label->isPlain, $label->lang);
        }

        return $this;
    }
604412
public static function create(array $constraints): ValidationClassMappingBuilderInterface
    {
        $self = new self();
        $self->constraints = [];
        foreach ($constraints as $constraint) {
            $self->addConstraint($constraint);
        }

        return $self;
    }
362218
public function addEagerConstraints(array $models)
    {
        $whereIn = $this->whereInMethod($this->parent, $this->localKey);

        $this->query->{$whereIn}(
            $this->foreignKey, $this->getKeys($models, $this->localKey)
        );
    }
91188
public function setProperties(array $properties)
    {
        foreach ($properties as $propertyIdent => $propertyMetadata) {
            if (isset($this->properties[$propertyIdent])) {
                $this->properties[$propertyIdent] = array_replace_recursive(
                    $this->properties[$propertyIdent],
                    $propertyMetadata
                );
            } else {
                $this->properties[$propertyIdent] = $propertyMetadata;
            }
        }

        return $this;
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
1189652
public function addConstraint($name, array $attributes = [])
    {
        if ($this->scope == 'alter') {
            $command = 'ADD CONSTRAINT';
        } else {
            $command = 'CONSTRAINT';
        }

        $sql = sprintf(
            '%s (%s) FOREIGN KEY (`%s`) REFERENCES %s(%s) ON %s',
            $command,
            $name,
            $attributes['target'],
            $attributes['table'],
            $attributes['references'],
            strtoupper($attributes['on'])
        );

        $this->sqls[] = $sql;

        return $this;
    }
313540
public function addEagerConstraints(array $models)
    {
        if (is_array($this->ownerKey)) { //Check for multi-columns relationship
            $keys = [];

            foreach ($this->ownerKey as $key) {
                $keys[] = $this->related->getTable().'.'.$key;
            }

            $this->query->whereIn($keys, $this->getEagerModelKeys($models));
        } else {
            // We'll grab the primary key name of the related models since it could be set to
            // a non-standard name and not "id". We will then construct the constraint for
            // our eagerly loading query so it returns the proper models from execution.
            $key = $this->related->getTable().'.'.$this->ownerKey;
            $this->query->whereIn($key, $this->getEagerModelKeys($models));
        }
    }
1198626
public function addEagerConstraints(array $models)
    {
        $whereIn = $this->whereInMethod($this->farParent, $this->localKey);

        $this->query->{$whereIn}(
            $this->getQualifiedFirstKeyName(), $this->getKeys($models, $this->localKey)
        );
    }
252472
public function dropForeignKey($columns, $constraint = null)
    {
        $action = DropForeignKey::build($this->table, $columns, $constraint);
        $this->actions->addAction($action);

        return $this;
    }
1351429
public function setConstraint($constraint) 
    {
        if (!$this->_isNumericArray($constraint)) {
            $constraint =  array ($constraint);    
        }
        $this->_fields['Constraint']['FieldValue'] = $constraint;
        return $this;
    }
328184
public function setProperties(array $properties = null)
    {
        ValidationUtility::ensureNullOrArrayOfType(
            '$properties', $properties, __NAMESPACE__ . '\Property');

        $this->properties = $properties;

        return $this;
    }
891926
public function addConstraints()
    {
        if (static::$constraints) {
            $this->query->where($this->foreignKey, '=', $this->getParentKey());

            $this->query->whereNotNull($this->foreignKey);
        }
    }
1139066
public function addConstraints()
    {
        if (static::$constraints) {
            // For belongs to relationships, which are essentially the inverse of has one
            // or has many relationships, we need to actually query on the primary key
            // of the related models matching on the foreign key that's on a parent.
            $this->query->where($this->otherKey, '=', $this->parent->{$this->foreignKey});
        }
    }