public function linkByKeys($relation, $keys, $removeKeys = null)
    {
        if ($relation->via !== null) {
            $this->linkJunctionByKeys($relation, $keys, $removeKeys);
        } else {
            $this->linkDirectByKeys($relation, $keys, $removeKeys);
        }
    }
public function linkByKeys($relation, $keys, $removeKeys = null)
    {
        if ($relation->via !== null) {
            $this->linkJunctionByKeys($relation, $keys, $removeKeys);
        } else {
            $this->linkDirectByKeys($relation, $keys, $removeKeys);
        }
    }
public function linkByKeys ( $ relation , $ keys , $ removeKeys = null ) { if ( $ relation -> via !== null ) { $ this -> linkJunctionByKeys ( $ relation , $ keys , $ removeKeys ) ; } else { $ this -> linkDirectByKeys ( $ relation , $ keys , $ removeKeys ) ; } }
Establishes the relationship between current model and records matching passed keys.
Their foreign key columns are updated to the primary key value of current model.

If the relationship involves a junction table, a new row will be inserted into the
junction table which contains the primary key values from both models.

Note that this method requires that the primary key value is not null.

If $removeKeys is null, $keys must be all records to remain associated, including those that do not change.

@param \yii\db\ActiveQuery $relation
@param array $keys primary keys of the records to be linked with the current model
@param array $removeKeys primary keys of records to be unlinked with the current model
@throws InvalidCallException if the method is unable to link two models.
Establishes the relationship between current model and records matching passed keys . Their foreign key columns are updated to the primary key value of current model .