public function cloneRelation(ActiveRecord $target, $except = ['id'])
    {
        $ids = $this->getViaIds(['*'])->all();
        array_walk($ids, function (&$v) use ($except) {
            $v = array_diff_key($v, array_flip($except));
        });
        return (new static($target, $this->relationName))->addViaIds($ids);
    }
public function cloneRelation(ActiveRecord $target, $except = ['id'])
    {
        $ids = $this->getViaIds(['*'])->all();
        array_walk($ids, function (&$v) use ($except) {
            $v = array_diff_key($v, array_flip($except));
        });
        return (new static($target, $this->relationName))->addViaIds($ids);
    }
public function cloneRelation ( ActiveRecord $ target , $ except = [ 'id' ] ) { $ ids = $ this -> getViaIds ( [ '*' ] ) -> all ( ) ; array_walk ( $ ids , function ( & $ v ) use ( $ except ) { $ v = array_diff_key ( $ v , array_flip ( $ except ) ) ; } ) ; return ( new static ( $ target , $ this -> relationName ) ) -> addViaIds ( $ ids ) ; }
Clones original model relations to target model
@param ActiveRecord $target
@param array $except exclude fields from cloning
@return mixed
Clones original model relations to target model