app/maguttiCms/Admin/Helpers/ModelReplicator.php
/**
     * Duplicate a many-to-many style relation where we are just attaching the
     * relation to the dupe
     *
     * @param Illuminate\Database\Eloquent\Relations\Relation $relation
     * @param string $relation_name
     * @param Illuminate\Database\Eloquent\Model $clone
     * @return void
     */
Duplicate a many-to-many style relation where we are just attaching the
relation to the dupe


Duplicate a many - to - many style relation where we are just attaching the relation to the dupe
protected function duplicatePivotedRelation($relation, $relation_name, $clone)
    {
        $relation->get()->each(function ($foreign) use ($clone, $relation_name) {
            $pivot_attributes = Arr::except($foreign->pivot->getAttributes(), [
                $foreign->pivot->getRelatedKey(),
                $foreign->pivot->getForeignKey(),
                $foreign->pivot->getCreatedAtColumn(),
                $foreign->pivot->getUpdatedAtColumn()
            ]);
            $clone->$relation_name()->attach($foreign, $pivot_attributes);
        });
    }
protected function duplicatePivotedRelation ( $ relation , $ relation_name , $ clone ) { $ relation -> get ( ) -> each ( function ( $ foreign ) use ( $ clone , $ relation_name ) { $ pivot_attributes = Arr :: except ( $ foreign -> pivot -> getAttributes ( ) , [ $ foreign -> pivot -> getRelatedKey ( ) , $ foreign -> pivot -> getForeignKey ( ) , $ foreign -> pivot -> getCreatedAtColumn ( ) , $ foreign -> pivot -> getUpdatedAtColumn ( ) ] ) ; $ clone -> $ relation_name ( ) -> attach ( $ foreign , $ pivot_attributes ) ; } ) ; }
Duplicate a many-to-many style relation where we are just attaching the
 relation to the dupe
Duplicate a many - to - many style relation where we are just attaching the relation to the dupe
// Loop trough current relations and attach to clone