<?php
 namespace App\ImportedDocument\EntityMatch; trait ExtSysCleanMatchesTrait { protected function cleanMatches() { $foundExtSysMatch = false; $bulkMatchesExact = $this->bulkMatches; foreach($this->bulkMatches as $idx=>$matchesList) { foreach($matchesList as $id=>$details) { if ($details['_matchedField']=='documentExtSys') { $foundExtSysMatch = true; } else { unset($bulkMatchesExact[$idx][$id]); } } } if ($foundExtSysMatch) { $this->bulkMatches = array_filter($bulkMatchesExact); } parent::cleanMatches(); } }