public function manyToMany($model, $associativeTable = null, $thisKey = null, $relatedKey = null)
	{
		$related   = $this->resolve($model);
		$names     = [strtolower($this->getModelName()), strtolower($related->getModelName())];
		$namespace = (!$this->namespace ? '' : $this->namespace . '_');

		// Sort names alphabetically so both sides of manyToMany will resolve to the same table name
		sort($names);

		// Default the keys and table if not set
		$associativeTable = $associativeTable ?: '#__' . $namespace . implode('_', $names);
		$thisKey          = $thisKey          ?: strtolower($this->getModelName()) . '_id';
		$relatedKey       = $relatedKey       ?: strtolower($related->getModelName()) . '_id';

		return new ManyToMany($this, $related, $associativeTable, $thisKey, $relatedKey);
	}
public function manyToMany($model, $associativeTable = null, $thisKey = null, $relatedKey = null)
	{
		$related   = $this->resolve($model);
		$names     = [strtolower($this->getModelName()), strtolower($related->getModelName())];
		$namespace = (!$this->namespace ? '' : $this->namespace . '_');

		// Sort names alphabetically so both sides of manyToMany will resolve to the same table name
		sort($names);

		// Default the keys and table if not set
		$associativeTable = $associativeTable ?: '#__' . $namespace . implode('_', $names);
		$thisKey          = $thisKey          ?: strtolower($this->getModelName()) . '_id';
		$relatedKey       = $relatedKey       ?: strtolower($related->getModelName()) . '_id';

		return new ManyToMany($this, $related, $associativeTable, $thisKey, $relatedKey);
	}
public function manyToMany ( $ model , $ associativeTable = null , $ thisKey = null , $ relatedKey = null ) { $ related = $ this -> resolve ( $ model ) ; $ names = [ strtolower ( $ this -> getModelName ( ) ) , strtolower ( $ related -> getModelName ( ) ) ] ; $ namespace = ( ! $ this -> namespace ? '' : $ this -> namespace . '_' ) ; // Sort names alphabetically so both sides of manyToMany will resolve to the same table name sort ( $ names ) ; // Default the keys and table if not set $ associativeTable = $ associativeTable ? : '#__' . $ namespace . implode ( '_' , $ names ) ; $ thisKey = $ thisKey ? : strtolower ( $ this -> getModelName ( ) ) . '_id' ; $ relatedKey = $ relatedKey ? : strtolower ( $ related -> getModelName ( ) ) . '_id' ; return new ManyToMany ( $ this , $ related , $ associativeTable , $ thisKey , $ relatedKey ) ; }
Retrieves a many to many model relationship

@param   string       $model             The name of the model to relate to the current one
@param   string       $associativeTable  The name of the intermediate table used to associate model->related
@param   string|null  $thisKey           The local key used on the associative table
@param   string|null  $relatedKey        The related key used on the associative table
@return  \Hubzero\Database\Relationship\ManyToMany
@since   2.0.0
Retrieves a many to many model relationship