map(function ($item, $key) use ($comparate) { $comparate = $this->getArrayableItems($comparate); if (! isset($comparate[$key])) { return $item; } if (Arr::accessible($item)) { $item = $this->getArrayableItems($item); $comparate = $this->getArrayableItems($comparate[$key]); $diff = array_udiff_assoc($item, $comparate, function ($a, $b) { if (Arr::accessible($a)) { return collect($this->getArrayableItems($a))->diffRecursive($b)->all(); } if ($a == $b) { return 0; } return $a < $b ? -1 : 1; }); return $diff; } return $item == $comparate[$key] ? null : $item; })->filter(); });