public static function cloneRelations($sources, $clones, $relations = [])
    {
        if (!is_array($sources)) {
            $sources = [$sources];
            $clones = [$clones];
        }
        foreach ($sources as $k => $source) {
            foreach ($relations as $j => $name) {
                list($name, $except) = is_array($name) ? [$j, $name] : [$name, ['id']];
                (new static($source, $name))->cloneRelation($clones[$k], $except);
            }
        }
    }
public static function cloneRelations($sources, $clones, $relations = [])
    {
        if (!is_array($sources)) {
            $sources = [$sources];
            $clones = [$clones];
        }
        foreach ($sources as $k => $source) {
            foreach ($relations as $j => $name) {
                list($name, $except) = is_array($name) ? [$j, $name] : [$name, ['id']];
                (new static($source, $name))->cloneRelation($clones[$k], $except);
            }
        }
    }
public static function cloneRelations ( $ sources , $ clones , $ relations = [ ] ) { if ( ! is_array ( $ sources ) ) { $ sources = [ $ sources ] ; $ clones = [ $ clones ] ; } foreach ( $ sources as $ k => $ source ) { foreach ( $ relations as $ j => $ name ) { list ( $ name , $ except ) = is_array ( $ name ) ? [ $ j , $ name ] : [ $ name , [ 'id' ] ] ; ( new static ( $ source , $ name ) ) -> cloneRelation ( $ clones [ $ k ] , $ except ) ; } } }
Clones relations from one models array to another
@param $sources
@param $clones
@param array $relations relation names
Clones relations from one models array to another