<?php

namespace App\Traits;

use Illuminate\Http\Request;

trait RemoveDuplicateEmailTraits
{
    public function cleanData($data, $existing)
    {

        foreach ($data as $key => $entry) {
            foreach ($existing as $exist) {
                if ($entry[0] == $exist->email_address) {
                    unset($data[$key]);
                }
            }
        }

        //re arrange the index/key of array
        return array_merge($data);
    }
}
