dep: package update
This commit is contained in:
+45
-1
@@ -5,12 +5,13 @@ namespace Illuminate\Support;
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Contracts\Support\CanBeEscapedWhenCastToString;
|
||||
use Illuminate\Support\Traits\EnumeratesValues;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use IteratorAggregate;
|
||||
use stdClass;
|
||||
|
||||
class LazyCollection implements Enumerable
|
||||
class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable
|
||||
{
|
||||
use EnumeratesValues, Macroable;
|
||||
|
||||
@@ -512,6 +513,25 @@ class LazyCollection implements Enumerable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any of the keys exist in the collection.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAny($key)
|
||||
{
|
||||
$keys = array_flip(is_array($key) ? $key : func_get_args());
|
||||
|
||||
foreach ($this as $key => $value) {
|
||||
if (array_key_exists($key, $keys)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenate values of a given key as a string.
|
||||
*
|
||||
@@ -1352,6 +1372,30 @@ class LazyCollection implements Enumerable
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return only unique items from the collection array.
|
||||
*
|
||||
* @param string|callable|null $key
|
||||
* @param bool $strict
|
||||
* @return static
|
||||
*/
|
||||
public function unique($key = null, $strict = false)
|
||||
{
|
||||
$callback = $this->valueRetriever($key);
|
||||
|
||||
return new static(function () use ($callback, $strict) {
|
||||
$exists = [];
|
||||
|
||||
foreach ($this as $key => $item) {
|
||||
if (! in_array($id = $callback($item, $key), $exists, $strict)) {
|
||||
yield $key => $item;
|
||||
|
||||
$exists[] = $id;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the keys on the underlying array.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user