public function on($rel, $aliasFrom = null, $aliasTo = null, $constraints = []) {
		$model = $rel->from();

		$aliasFrom = $aliasFrom ?: $model::meta('name');
		$aliasTo = $aliasTo ?: $rel->name();

		$keyConstraints = [];
		foreach ($rel->key() as $from => $to) {
			$keyConstraints["{$aliasFrom}.{$from}"] = "{$aliasTo}.{$to}";
		}

		$mapAlias = [$model::meta('name') => $aliasFrom, $rel->name() => $aliasTo];

		$relConstraints = $this->_on((array) $rel->constraints(), $aliasFrom, $aliasTo, $mapAlias);
		$constraints = $this->_on($constraints, $aliasFrom, $aliasTo, []);

		return $constraints + $relConstraints + $keyConstraints;
	}
public function on($rel, $aliasFrom = null, $aliasTo = null, $constraints = []) {
		$model = $rel->from();

		$aliasFrom = $aliasFrom ?: $model::meta('name');
		$aliasTo = $aliasTo ?: $rel->name();

		$keyConstraints = [];
		foreach ($rel->key() as $from => $to) {
			$keyConstraints["{$aliasFrom}.{$from}"] = "{$aliasTo}.{$to}";
		}

		$mapAlias = [$model::meta('name') => $aliasFrom, $rel->name() => $aliasTo];

		$relConstraints = $this->_on((array) $rel->constraints(), $aliasFrom, $aliasTo, $mapAlias);
		$constraints = $this->_on($constraints, $aliasFrom, $aliasTo, []);

		return $constraints + $relConstraints + $keyConstraints;
	}
public function on ( $ rel , $ aliasFrom = null , $ aliasTo = null , $ constraints = [ ] ) { $ model = $ rel -> from ( ) ; $ aliasFrom = $ aliasFrom ? : $ model :: meta ( 'name' ) ; $ aliasTo = $ aliasTo ? : $ rel -> name ( ) ; $ keyConstraints = [ ] ; foreach ( $ rel -> key ( ) as $ from => $ to ) { $ keyConstraints [ "{$aliasFrom}.{$from}" ] = "{$aliasTo}.{$to}" ; } $ mapAlias = [ $ model :: meta ( 'name' ) => $ aliasFrom , $ rel -> name ( ) => $ aliasTo ] ; $ relConstraints = $ this -> _on ( ( array ) $ rel -> constraints ( ) , $ aliasFrom , $ aliasTo , $ mapAlias ) ; $ constraints = $ this -> _on ( $ constraints , $ aliasFrom , $ aliasTo , [ ] ) ; return $ constraints + $ relConstraints + $ keyConstraints ; }
Build the `ON` constraints from a `Relationship` instance

@param object $rel A Relationship instance
@param string $fromAlias Set a specific alias for the `'from'` `Model`.
@param string $toAlias Set a specific alias for `'to'` `Model`.
@param array $constraints Array of additionnal $constraints.
@return array A constraints array.
Build the ON constraints from a Relationship instance