---
description: >-
  https://www.itsolutionstuff.com/post/laravel-copy-record-using-eloquent-replicate-exampleexample.html
---

# Laravel Copy Record using Eloquent Replicate Example

## Laravel Copy Record using Eloquent Replicate Example

By Hardik Savani March 26, 2021 Category : Laravel![](https://a.vdo.ai/core/assets/img/cross.svg)PauseUnmuteLoaded: 2.33%Fullscreen[![VDO.AI](https://a.vdo.ai/core/assets/img/logo.svg)](https://vdo.ai/?utm_medium=video\&utm_term=itsolutionstuff.com\&utm_source=vdoai_logo)Hi,

Now, let's see article of laravel copy row using replicate. In this article, we will implement a laravel duplicate record. this example will help you laravel eloquent copy record example. you will learn laravel eloquent replicate example.

Sometime we need to create duplicate record on same database table. at that time if we create that record manually then it can take time and can generate error. as specially issue when we have 10 or 20 fields on that table. so laravel eloquent provide replicate() that can help to create duplicate entry on same table.

you can easily use replicate() with laravel 8 version.

Let's see two simple example how to create duplicate record using replicate().

**Example 1**

```
<?php  namespace App\Http\Controllers;  use App\Models\Product;  class SignaturePadController extends Controller{    /**     * Write code on Method     *     * @return response()     */    public function index()    {        $product = Product::find(2);          $newProduct = $product->replicate()->save();          dd($newProduct);    }}
```

Output:

![](https://www.itsolutionstuff.com/upload/laravel-replicate.png)

**Example 2: Update Some Fields**

Read Also: [Delete All Records from Table in Laravel Eloquent](https://www.itsolutionstuff.com/post/delete-all-records-from-table-in-laravel-eloquentexample.html)

```
<?php  namespace App\Http\Controllers;  use App\Models\Product;  class SignaturePadController extends Controller{    /**     * Write code on Method     *     * @return response()     */    public function index()    {        $product = Product::find(2);          $newProduct = $product->replicate();        $newProduct->amount = 100;        $newProduct->save();          dd($newProduct);    }}
```

Output:

![](https://www.itsolutionstuff.com/upload/laravel-replicate-2.png)

i hope it can help you...
