@@ 210-223 (lines=14) @@ | ||
207 | * @param \ArrayAccess|array $items |
|
208 | * @return static |
|
209 | */ |
|
210 | public function diff($items) |
|
211 | { |
|
212 | $diff = new static([], $this->model); |
|
213 | ||
214 | $dictionary = $this->getDictionary($items); |
|
215 | ||
216 | foreach ($this->items as $item) { |
|
217 | if (!isset($dictionary[(string) $item->getKey()])) { |
|
218 | $diff->add($item); |
|
219 | } |
|
220 | } |
|
221 | ||
222 | return $diff; |
|
223 | } |
|
224 | ||
225 | /** |
|
226 | * Intersect the collection with the given items. |
|
@@ 231-244 (lines=14) @@ | ||
228 | * @param \ArrayAccess|array $items |
|
229 | * @return static |
|
230 | */ |
|
231 | public function intersect($items) |
|
232 | { |
|
233 | $intersect = new static([], $this->model); |
|
234 | ||
235 | $dictionary = $this->getDictionary($items); |
|
236 | ||
237 | foreach ($this->items as $item) { |
|
238 | if (isset($dictionary[(string) $item->getKey()])) { |
|
239 | $intersect->add($item); |
|
240 | } |
|
241 | } |
|
242 | ||
243 | return $intersect; |
|
244 | } |
|
245 | ||
246 | /** |
|
247 | * Return only unique items from the collection. |