app/maguttiCms/Admin/Helpers/ModelReplicator.php
/**
     * Duplicate a one-to-many style relation where the foreign model is ALSO
     * cloned and then associated
     *
     * @param Illuminate\Database\Eloquent\Relations\Relation $relation
     * @param string $relation_name
     * @param Illuminate\Database\Eloquent\Model $clone
     * @return void
     */
Duplicate a one-to-many style relation where the foreign model is ALSO
cloned and then associated


Duplicate a one - to - many style relation where the foreign model is ALSO cloned and then associated
protected function duplicateDirectRelation($relation, $relation_name, $clone)
    {
        $relation->get()->each(function ($foreign) use ($clone, $relation_name) {
            $foreign_key = $this->resolvePrimaryKey($relation_name);
            $cloned_relation = $foreign->replicate($this->uniqueFields);
            $cloned_relation->$foreign_key = $clone->id; 
            $cloned_relation->save();
        });
    }
protected function duplicateDirectRelation ( $ relation , $ relation_name , $ clone ) { $ relation -> get ( ) -> each ( function ( $ foreign ) use ( $ clone , $ relation_name ) { $ foreign_key = $ this -> resolvePrimaryKey ( $ relation_name ) ; $ cloned_relation = $ foreign -> replicate ( $ this -> uniqueFields ) ; $ cloned_relation -> $ foreign_key = $ clone -> id ; $ cloned_relation -> save ( ) ; } ) ; }
Duplicate a one-to-many style relation where the foreign model is ALSO
 cloned and then associated
Duplicate a one - to - many style relation where the foreign model is ALSO cloned and then associated
// Loop trough current relations and clone it // add