laravel eloquent duplicate record
snippet in php

laravel eloquent duplicate record

user2543

// Retrieve the first task
$task = Task::first();

$newTask = $task->replicate();
$newTask->project_id = 16; // the new project_id
$newTask->save();