src/mako/database/midgard/relations/ManyToMany.php
public function link($id, array $attributes = []): bool
	{
		$success = true;

		$foreignKey = $this->getForeignKey();

		$foreignKeyValue = $this->parent->getPrimaryKeyValue();

		$junctionKey = $this->getJunctionKey();

		foreach($this->getJunctionKeys($id) as $key => $id)
		{
			$columns = [$foreignKey  => $foreignKeyValue, $junctionKey => $id];

			$success = $success && $this->junction()->insert($columns + $this->getJunctionAttributes($key, $attributes));
		}

		return $success;
	}
public function link($id, array $attributes = []): bool
	{
		$success = true;

		$foreignKey = $this->getForeignKey();

		$foreignKeyValue = $this->parent->getPrimaryKeyValue();

		$junctionKey = $this->getJunctionKey();

		foreach($this->getJunctionKeys($id) as $key => $id)
		{
			$columns = [$foreignKey  => $foreignKeyValue, $junctionKey => $id];

			$success = $success && $this->junction()->insert($columns + $this->getJunctionAttributes($key, $attributes));
		}

		return $success;
	}
public function link ( $ id , array $ attributes = [ ] ) : bool { $ success = true ; $ foreignKey = $ this -> getForeignKey ( ) ; $ foreignKeyValue = $ this -> parent -> getPrimaryKeyValue ( ) ; $ junctionKey = $ this -> getJunctionKey ( ) ; foreach ( $ this -> getJunctionKeys ( $ id ) as $ key => $ id ) { $ columns = [ $ foreignKey => $ foreignKeyValue , $ junctionKey => $ id ] ; $ success = $ success && $ this -> junction ( ) -> insert ( $ columns + $ this -> getJunctionAttributes ( $ key , $ attributes ) ) ; } return $ success ; }
Links related records.

@param  mixed $id         Id, model or an array of ids and/or models
@param  array $attributes Junction attributes
@return bool
Links related records .