Adds 'on' eloquent method to a given properties.

@param string $properties
@param CrestApps\CodeGenerator\Models\ForeignConstraint $constraint

@return $this
12815
protected function addOnConstraint(&$properties, ForeignConstraint $constraint)
    {
        $properties .= $this->getPropertyBaseSpace(18, true) . sprintf("->on('%s')", $constraint->on);

        return $this;
    }
1374280
public function on($foreignKey, $key = null) {
        if (is_array($foreignKey)) {
            $this->_conditions = array_replace($this->_conditions, $foreignKey);
        } else {
            $this->_conditions[$foreignKey] = $key;
        }

        return $this;
    }
380184
public function addConstraints()
    {
        if (static::$constraints) {
            $table = $this->related->getTable();

            $this->query->where($table.'.'.$this->otherKey, '=', $this->parent->{$this->foreignKey});
        }
    }
251785
public function addPropertyConstraint($property, Constraint $constraint)
    {
        if (!isset($this->properties[$property])) {
            $this->properties[$property] = new PropertyMetadata($this->getClassName(), $property);

            $this->addPropertyMetadata($this->properties[$property]);
        }

        $constraint->addImplicitGroupName($this->getDefaultGroup());

        $this->properties[$property]->addConstraint($constraint);

        return $this;
    }
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;
    }
349205
public function visitOneOfConstraint(Generic\OneOfConstraint $constraint)
    {
        if (1 === count($constraint->schemas())) {
            $schemas = $constraint->schemas();

            return $schemas[0]->accept($this);
        }

        $validResults = array();
        foreach ($constraint->schemas() as $schema) {
            $result = $schema->accept($this);
            if ($result->isValid()) {
                $validResults[] = $result;
            }
        }

        if (1 === count($validResults)) {
            return array_shift($validResults);
        }

        return $this->createSingleIssueResult($constraint);
    }
1366318
public function applyConstraints($constraints, EloquentBuilder &$query, Field $fieldObject)
	{
		$configConstraints = $fieldObject->getOption('constraints');

		if (sizeof($configConstraints))
		{
			//iterate over the config constraints
			foreach ($configConstraints as $key => $relationshipName)
			{
				//now that we're looping through the constraints, check to see if this one was supplied
				if (isset($constraints[$key]) && $constraints[$key] && sizeof($constraints[$key]))
				{
					//first we get the other model and the relationship field on it
					$model = $this->config->getDataModel();
					$relatedModel = $model->{$fieldObject->getOption('field_name')}()->getRelated();
					$otherModel = $model->{$key}()->getRelated();

					//set the data model for the config
					$this->config->setDataModel($otherModel);
					$otherField = $this->make($relationshipName, array('type' => 'relationship'), false);

					//constrain the query
					$otherField->constrainQuery($query, $relatedModel, $constraints[$key]);

					//set the data model back to the original
					$this->config->setDataModel($model);
				}
			}
		}
	}
1044931
public function setOptionsProperty(array $properties)
    {
        if (Helpers::isKeyExists($properties, 'options') && is_array($properties['options'])) {
            $labels = $this->transferOptionsToLabels($properties['options']);

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

        }

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

            $this->query->whereNotNull($this->foreignKey);
        }
    }
908974
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;
    }
1257071
public function addConstraints()
    {
        if (static::$constraints)
        {
            $this->query->where($this->foreignKey, '=', $this->getParentKey());

            $this->query->whereNotNull($this->foreignKey);

            $this->query->where($this->rootKey, '=', $this->getRootKey());

            $this->query->whereNotNull($this->rootKey);

        }
    }
358548
public function configure($properties = array())
    {
        foreach ($properties as $name => $value) {
            if ( ! property_exists($this, $name)) {
                throw new PropertyDoesNotExist(sprintf('Property "%s" does not exist in %s', $name,
                    get_called_class()));
            }
            $this->{$name} = $value;
        }
    }
528525
public function visitPropertiesConstraint(ObjectValue\PropertiesConstraint $constraint)
    {
        $value = $this->currentValue();
        if (!$value instanceof Value\ObjectValue) {
            return $this->createResult();
        }

        $result = $this->createResult();
        $matchedProperties = array();

        // properties
        foreach ($constraint->schemas() as $property => $schema) {
            if ($value->has($property)) {
                $matchedProperties[$property] = true;
                $result = $result->merge(
                    $this->validateObjectProperty($property, $schema)
                );
            } elseif (null !== $schema->defaultValue()) {
                $result = $result->merge(
                    $this->createResult(
                        array(),
                        array($this->createDefaultValueMatch($schema, $property))
                    )
                );
            }
        }

        // pattern properties
        foreach ($constraint->patternSchemas() as $pattern => $schema) {
            $pattern = $this->wrapPattern($pattern);

            foreach ($value->keys() as $property) {
                if (preg_match($pattern, $property)) {
                    $matchedProperties[$property] = true;
                    $result = $result->merge(
                        $this->validateObjectProperty($property, $schema)
                    );
                }
            }
        }

        // additional properties
        foreach ($value->keys() as $property) {
            if (!array_key_exists($property, $matchedProperties)) {
                $result = $result->merge(
                    $this->validateObjectProperty(
                        $property,
                        $constraint->additionalSchema()
                    )
                );
            }
        }

        return $result;
    }
380419
public function mergeConstraints(self $source)
    {
        if ($source->isGroupSequenceProvider()) {
            $this->setGroupSequenceProvider(true);
        }

        foreach ($source->getConstraints() as $constraint) {
            $this->addConstraint(clone $constraint);
        }

        foreach ($source->getConstrainedProperties() as $property) {
            foreach ($source->getPropertyMetadata($property) as $member) {
                $member = clone $member;

                foreach ($member->getConstraints() as $constraint) {
                    if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
                        $member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
                    }

                    $constraint->addImplicitGroupName($this->getDefaultGroup());
                }

                $this->addPropertyMetadata($member);

                if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
                    $property = $member->getPropertyName();

                    if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
                        $this->properties[$property] = $member;
                    } elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
                        $this->getters[$property] = $member;
                    }
                }
            }
        }
    }
1059069
public function matching($constraint)
    {
        $this->constraint = $constraint;
        $this->queryBuilder->where($constraint);
        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;
    }
927063
public function addConstraints($fieldName, Schema $property, DocumentModel $model)
    {
        $constraints = $model->getConstraints($fieldName);

        if (!is_array($constraints)) {
            return $property;
        }

        foreach ($constraints as $constraint) {
            $isSupported = false;
            foreach ($this->builders as $builder) {
                if ($builder->supportsConstraint($constraint->name, $constraint->options)) {
                    $property = $builder->buildConstraint($fieldName, $property, $model, $constraint->options);
                    $isSupported = true;
                }
            }

            if (!$isSupported) {
                /**
                 * unknown/not supported constraints will be added to the 'x-constraints' schema property.
                 * this allows others (possibly schema constraints) to pick it up and implement more advanced logic.
                 */
                 $property->addConstraint($constraint->name);
            }
        }

        return $property;
    }