noodleware / replicata
A Laravel package for deep cloning Eloquent models and their nested relationships.
v1.0.0
2025-03-05 22:18 UTC
Requires
- php: ^8.2
- illuminate/database: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.21
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.