noodleware/replicata

A Laravel package for deep cloning Eloquent models and their nested relationships.

v1.0.0 2025-03-05 22:18 UTC

This package is auto-updated.

Last update: 2025-07-05 23:08:49 UTC


README

Replicata is a simple Laravel package that provides a static class for replicating any Eloquent model along with its specified relationships.

Installation

To install Replicata, use Composer:

composer require noodleware/replicata

Usage

Replicata allows you to quickly replicate a model and its related data with a simple static method call.

Example

use Noodleware\Replicata\Replicata;

$model = Model::find(1);

$clonedModel = Replicata::replicate($model, ['relation1', 'relation2.subRelation1']);

This will:

  • Clone the given model.
  • Clone the specified relationships, including nested relationships if provided.

Supported Relationship Types

Replicata supports the following relationship types:

  • BelongsToMany
  • HasMany
  • HasOne
  • MorphMany
  • MorphOne
  • MorphToMany

License

This package is open-source under the MIT License.