laravel eloquent no duplicates code example
Example 1: laravel collection remove duplicates
$unique = $collection->unique();
Example 2: laravel eloquent duplicate record
// Retrieve the first task
$task = Task::first();
$newTask = $task->replicate();
$newTask->project_id = 16; // the new project_id
$newTask->save();