Advertisements

Find duplicate users in laravel

Advertisements

Find duplicate users in laravel

public function duplicateUsers(){
	$users = User::all();
	$unique_users = $users->unique(['email']);
	$duplicates = $users->diff($unique_users);
	return $duplicates;
}

For more code examples click here. Read laravel collections.