Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Replicate

Laravel Replicate Laravel Package

halilcosdu/laravel-replicate

A Laravel package for duplicating Eloquent models and their relationships via a simple API. Define which relations and columns to replicate, then create deep copies for templates, drafts, or versioned records without manual clone logic.

View on GitHub
Deep Wiki
Context7

★ Replicate Laravel PHP client

Frequently asked questions about Laravel Replicate
How do I install halilcosdu/laravel-replicate in a Laravel application?
Install it with Composer using composer require halilcosdu/laravel-replicate, optionally publish the package config, and add the replication trait to the Eloquent models that need cloning. The package follows the standard Laravel package shape with a service provider, config file, and model trait. Before installing, check the package composer.json against your PHP and Laravel versions, especially if you are considering the 2.0 release.
Does laravel-replicate duplicate relationships as well as model attributes?
Yes. The package is designed for deep copies: you define which relations and columns should be replicated, and it creates copies without manual clone logic. That makes it useful for templates, drafts, and versioned records where related rows must follow the parent model. You should still confirm the configured relationship depth and default behavior for your models, particularly after the 2.0 major version bump.
Which Laravel and PHP versions does laravel-replicate support?
The exact support matrix is defined by the package composer.json constraints, not by the release notes. Because the 2.0.0 changelog is limited to a release PR link, you should read the diff and confirm the new minimum PHP and Illuminate versions before upgrading. Verify that your runtime matches those constraints and that your CI matrix covers the Laravel major you deploy.
What changed between laravel-replicate 1.3.0 and 2.0.0?
The 2.0.0 changelog provides only a release PR link and no upgrade guide, so the breaking changes are not documented in a readable summary. A major version bump under semver strongly signals backward-incompatible changes, likely around trait names, namespaces, config keys, method signatures, minimum versions, or replication defaults. Read the v1.3.0...v2.0.0 compare diff across src and config before assuming an in-place upgrade is safe.
Should I upgrade to laravel-replicate 2.0 immediately?
Do not upgrade in place on the strength of a bare release tag. Pin to ^1.3 as your default state, then create an isolated branch, bump to ^2.0, run the full test suite, and manually review the source and config diff. Treat trait or config key changes as codemod work and any shift in replication semantics as a behavioral regression test task.
How should I handle unique keys and soft deletes when replicating Eloquent models?
Unique columns, soft deletes, global scopes, timestamps, and observer firing are the usual edge cases in clone logic. Add regression tests that assert cloned row counts, foreign-key re-pointing, and whether unique values are preserved or regenerated. Because the 2.0 release notes do not describe default replication semantics, verify these behaviors explicitly rather than relying on v1 assumptions.
Does laravel-replicate work with UUID or ULID primary keys and polymorphic relations?
UUID and ULID keys and polymorphic relations are common edge cases for any model cloning package. You should test that keys are regenerated correctly where required and that polymorphic foreign keys are re-pointed to the copied parent. Run those checks against your actual model layer before committing to the upgrade or to a new integration.
How do I test that replicated models and relationships are correct?
Write regression tests that assert row counts for the parent and each replicated relation, foreign-key re-pointing, and the preserved or regenerated state of unique columns. Also verify event and observer behavior if your application depends on it. Run the suite against each database driver you support, because MySQL, PostgreSQL, and SQLite diverge on constraint and type behavior.
Is laravel-replicate safe for production and high-volume cloning?
The package is a narrow, additive utility that keeps blast radius small if removed, but it writes data and has a single-maintainer project with a small community. A defect can surface as duplicated or corrupted records rather than a visible error. It is a reasonable fit for templates, drafts, and seeding, but a poor fit when replication must be transactional across many models, auditable, or run at high volume.
What are the alternatives to laravel-replicate for duplicating Eloquent models?
You can implement cloning with Eloquent replicate(), explicit attribute overrides, and manual relation copying, or build a first-party service that encodes your business rules. A custom implementation is more defensible when replication must be transactional, auditable, or tuned for high volume. The package remains convenient when you want configured deep copies of relations without writing the clone logic yourself.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect