bkwld/cloner
A Laravel Eloquent trait that clones models with their relationships, including files, and can duplicate records to another database connection. Configure cloneable relations and call duplicate() or duplicateTo().
Architecture fit
use \Bkwld\Cloner\Cloneable) that layers on top of Model::replicate(), so it inherits the framework's own attribute-copying semantics rather than introducing a parallel persistence layer. Low architectural intrusion: no base model to inherit, no new query builder, no schema changes.$cloneable_relations / $cloneable_files configuration.duplicateTo('connection')) is the architecturally interesting piece — it turns the package from a convenience into a data-seeding/tenant-provisioning primitive, but it implicitly assumes schema parity between connections.Integration feasibility
composer require bkwld/cloner is the entire install. Realistic effort for a first working clone: under a day for one model.replicate() behaviour is sensitive to framework internals. Verify composer.json constraints against the target app version before committing.Storage facade and disks (S3/Spaces compatible) or raw local paths, since that determines whether cloud storage and CDN-backed assets are safe to clone.Technical risk
morphMany/morphTo) relations, belongsToMany pivot data, and deep nested graphs. Any gap here produces silently incomplete clones — the worst failure class, because it looks like success.Key questions
morphMany, belongsToMany with pivot attributes, and self-referencing/cyclic relations — and does it guard against infinite recursion?duplicateTo, is schema parity validated, or does it fail opaquely at insert time?Stack fit
Migration path
hasMany, no unique constraints on copied columns).Compatibility
composer.json framework constraints vs. the app's Laravel version; (b) trait/method collisions with existing traits or overrides on replicate(), save(), and model events.SoftDeletes, and global scopes — global scopes in particular can silently truncate a relation graph during cloning.Sequencing
CloneService so application code never calls duplicate() directly — this is the single highest-leverage decision, as it lets you fork, queue, or replace the package later without touching call sites.Maintenance
composer.lock; treat upgrades as requiring a test run, since the package overrides framework behaviour.Support
Scaling
Failure modes to instrument
Ramp-up
$cloneable_relations/$cloneable_files expectations, the CloneService wrapper, queue requirements, and the model checklist. Without that documentation, new models will be added inconsistently and produce silently incomplete clones.How can I help you explore Laravel packages today?