Koleksi Laravel Hapus duplikat
$unique = $collection->unique();
Frightened Fox
$unique = $collection->unique();
$array = array(1, 2, 2, 3);
$array = array_unique($array); // Array is now (1, 2, 3)
$users = Users::all();
$usersUnique = $users->unique('id');
$usersDupes = $users->diff($usersUnique);
dd($users, $usersUnique, $usersDupes);