PHPackages                             coliving/laravel-duplicate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. coliving/laravel-duplicate

ActiveLibrary[Database &amp; ORM](/categories/database)

coliving/laravel-duplicate
==========================

Duplicate any Eloquent model along with its underlying relationships

5.4.0(1y ago)362.9k↓35.9%2[2 PRs](https://github.com/dungnh/laravel-duplicate/pulls)MITPHPPHP ^7.4|^8.0|^8.1||^8.2|^8.3|^8.4

Since Dec 28Pushed 1y agoCompare

[ Source](https://github.com/dungnh/laravel-duplicate)[ Packagist](https://packagist.org/packages/coliving/laravel-duplicate)[ RSS](/packages/coliving-laravel-duplicate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (17)Used By (0)

### This is fork from Neurony/laravel-duplicate to make it works with new Laravel 12.x

[](#this-is-fork-from-neuronylaravel-duplicate-to-make-it-works-with-new-laravel-12x)

---

### Duplicate any Eloquent model along with its relationships

[](#duplicate-any-eloquent-model-along-with-its-relationships)

- [Overview](#overview)
- [Installation](#installation)
- [Usage](#usage)
- [Customisations](#customisations)
- [Events](#events)

### Overview

[](#overview)

This package allows you to duplicate any Eloquent model record along with its underlying relationships.

Relationship types that can and will make sense to be duplicated: `hasOne`, `morphOne`, `hasMany`, `morphMany`, `belongsToMany`, `morphToMany`

### Installation

[](#installation)

Install the package via Composer:

```
composer require coliving/laravel-duplicate

```

### Usage

[](#usage)

##### Step 1

[](#step-1)

Your Eloquent models should use the `Neurony\Duplicate\Traits\HasDuplicates` trait and the `Neurony\Duplicate\Options\DuplicateOptions` class.

The trait contains an abstract method `getDuplicateOptions()` that you must implement yourself.

Here's an example of how to implement the trait:

```
