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.5.0(2mo ago)367.1k↓69.9%2[2 PRs](https://github.com/dungnh/laravel-duplicate/pulls)MITPHPPHP ^8.3 || ^8.4

Since Dec 28Pushed 2mo 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 3d ago

READMEChangelog (7)Dependencies (10)Versions (19)Used By (0)

### This is fork from Neurony/laravel-duplicate to make it work with Laravel 13.x

[](#this-is-fork-from-neuronylaravel-duplicate-to-make-it-work-with-laravel-13x)

---

### 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:

```
