LazyCollection
Implements
Uses
Properties
$source callable|static
The source from which to generate items.
Methods
__construct ( $source ) : void
Create a new lazy collection instance.
Parameters
- $source mixed
range ( $from , $to ) : static
Create a collection with the given range.
Parameters
- $from int
- $to int
all ( ) : array
Get all items in the enumerable.
eager ( ) : static
Eager load all items into a new lazy collection backed by an array.
remember ( ) : static
Cache values as they're enumerated.
avg ( $callback ) : mixed
Get the average value of a given key.
Parameters
- $callback callable|string|null
median ( $key ) : mixed
Get the median of a given key.
Parameters
- $key string|array|null
mode ( $key ) : array|null
Get the mode of a given key.
Parameters
- $key string|array|null
collapse ( ) : static
Collapse the collection of items into a single array.
contains ( $key , $operator , $value ) : bool
Determine if an item exists in the enumerable.
Parameters
- $key mixed
- $operator mixed
- $value mixed
doesntContain ( $key , $operator , $value ) : bool
Determine if an item is not contained in the enumerable.
Parameters
- $key mixed
- $operator mixed
- $value mixed
crossJoin ( $arrays ) : static
Cross join the given iterables, returning all possible permutations.
Parameters
- $arrays array
countBy ( $countBy ) : static
Count the number of items in the collection by a field or using a callback.
Parameters
- $countBy callable|string
diff ( $items ) : static
Get the items that are not present in the given items.
Parameters
- $items mixed
diffUsing ( $items , callable $callback ) : static
Get the items that are not present in the given items, using the callback.
Parameters
- $items mixed
- $callback callable
diffAssoc ( $items ) : static
Get the items whose keys and values are not present in the given items.
Parameters
- $items mixed
diffAssocUsing ( $items , callable $callback ) : static
Get the items whose keys and values are not present in the given items, using the callback.
Parameters
- $items mixed
- $callback callable
diffKeys ( $items ) : static
Get the items whose keys are not present in the given items.
Parameters
- $items mixed
diffKeysUsing ( $items , callable $callback ) : static
Get the items whose keys are not present in the given items, using the callback.
Parameters
- $items mixed
- $callback callable
duplicates ( $callback , $strict ) : static
Retrieve duplicate items.
Parameters
- $callback callable|string|null
- $strict bool
duplicatesStrict ( $callback ) : static
Retrieve duplicate items using strict comparison.
Parameters
- $callback callable|string|null
except ( $keys ) : static
Get all items except for those with the specified keys.
Parameters
- $keys mixed
filter ( callable $callback ) : static
Run a filter over each of the items.
Parameters
- $callback callable|null
first ( callable $callback , $default ) : mixed
Get the first item from the enumerable passing the given truth test.
Parameters
- $callback callable|null
- $default mixed
flatten ( $depth ) : static
Get a flattened list of the items in the collection.
Parameters
- $depth int
flip ( ) : static
Flip the items in the collection.
get ( $key , $default ) : mixed
Get an item by key.
Parameters
- $key mixed
- $default mixed
groupBy ( $groupBy , $preserveKeys ) : static
Group an associative array by a field or using a callback.
Parameters
- $groupBy array|callable|string
- $preserveKeys bool
keyBy ( $keyBy ) : static
Key an associative array by a field or using a callback.
Parameters
- $keyBy callable|string
has ( $key ) : bool
Determine if an item exists in the collection by key.
Parameters
- $key mixed
hasAny ( $key ) : bool
Determine if any of the keys exist in the collection.
Parameters
- $key mixed
implode ( $value , $glue ) : string
Concatenate values of a given key as a string.
Parameters
- $value string
- $glue string|null
intersect ( $items ) : static
Intersect the collection with the given items.
Parameters
- $items mixed
intersectByKeys ( $items ) : static
Intersect the collection with the given items by key.
Parameters
- $items mixed
isEmpty ( ) : bool
Determine if the items are empty or not.
containsOneItem ( ) : bool
Determine if the collection contains a single item.
join ( $glue , $finalGlue ) : string
Join all items from the collection using a string. The final items can use a separate glue string.
Parameters
- $glue string
- $finalGlue string
keys ( ) : static
Get the keys of the collection items.
last ( callable $callback , $default ) : mixed
Get the last item from the collection.
Parameters
- $callback callable|null
- $default mixed
pluck ( $value , $key ) : static
Get the values of a given key.
Parameters
- $value string|array
- $key string|null
map ( callable $callback ) : static
Run a map over each of the items.
Parameters
- $callback callable
mapToDictionary ( callable $callback ) : static
Run a dictionary map over the items.
Parameters
- $callback callable
mapWithKeys ( callable $callback ) : static
Run an associative map over each of the items.
Parameters
- $callback callable
merge ( $items ) : static
Merge the collection with the given items.
Parameters
- $items mixed
mergeRecursive ( $items ) : static
Recursively merge the collection with the given items.
Parameters
- $items mixed
combine ( $values ) : static
Create a collection by using this collection for keys and another for its values.
Parameters
- $values mixed
union ( $items ) : static
Union the collection with the given items.
Parameters
- $items mixed
nth ( $step , $offset ) : static
Create a new collection consisting of every n-th element.
Parameters
- $step int
- $offset int
only ( $keys ) : static
Get the items with the specified keys.
Parameters
- $keys mixed
concat ( $source ) : static
Push all of the given items onto the collection.
Parameters
- $source iterable
random ( $number ) : static|mixed
Get one or a specified number of items randomly from the collection.
Parameters
- $number int|null
replace ( $items ) : static
Replace the collection items with the given items.
Parameters
- $items mixed
replaceRecursive ( $items ) : static
Recursively replace the collection items with the given items.
Parameters
- $items mixed
reverse ( ) : static
Reverse items order.
search ( $value , $strict ) : mixed
Search the collection for a given value and return the corresponding key if successful.
Parameters
- $value mixed
- $strict bool
shuffle ( $seed ) : static
Shuffle the items in the collection.
Parameters
- $seed int|null
sliding ( $size , $step ) : static
Create chunks representing a "sliding window" view of the items in the collection.
Parameters
- $size int
- $step int
skip ( $count ) : static
Skip the first {$count} items.
Parameters
- $count int
skipUntil ( $value ) : static
Skip items in the collection until the given condition is met.
Parameters
- $value mixed
skipWhile ( $value ) : static
Skip items in the collection while the given condition is met.
Parameters
- $value mixed
slice ( $offset , $length ) : static
Get a slice of items from the enumerable.
Parameters
- $offset int
- $length int|null
split ( $numberOfGroups ) : static
Split a collection into a certain number of groups.
Parameters
- $numberOfGroups int
sole ( $key , $operator , $value ) : mixed
Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
Parameters
- $key mixed
- $operator mixed
- $value mixed
firstOrFail ( $key , $operator , $value ) : mixed
Get the first item in the collection but throw an exception if no matching items exist.
Parameters
- $key mixed
- $operator mixed
- $value mixed
chunk ( $size ) : static
Chunk the collection into chunks of the given size.
Parameters
- $size int
splitIn ( $numberOfGroups ) : static
Split a collection into a certain number of groups, and fill the first groups completely.
Parameters
- $numberOfGroups int
chunkWhile ( callable $callback ) : static
Chunk the collection into chunks with a callback.
Parameters
- $callback callable
sort ( $callback ) : static
Sort through each item with a callback.
Parameters
- $callback callable|null|int
sortDesc ( $options ) : static
Sort items in descending order.
Parameters
- $options int
sortBy ( $callback , $options , $descending ) : static
Sort the collection using the given callback.
Parameters
- $callback callable|string
- $options int
- $descending bool
sortByDesc ( $callback , $options ) : static
Sort the collection in descending order using the given callback.
Parameters
- $callback callable|string
- $options int
sortKeys ( $options , $descending ) : static
Sort the collection keys.
Parameters
- $options int
- $descending bool
sortKeysDesc ( $options ) : static
Sort the collection keys in descending order.
Parameters
- $options int
sortKeysUsing ( callable $callback ) : static
Sort the collection keys using a callback.
Parameters
- $callback callable
take ( $limit ) : static
Take the first or last {$limit} items.
Parameters
- $limit int
takeUntil ( $value ) : static
Take items in the collection until the given condition is met.
Parameters
- $value mixed
takeUntilTimeout ( DateTimeInterface $timeout ) : static
Take items in the collection until a given point in time.
Parameters
- $timeout DateTimeInterface
takeWhile ( $value ) : static
Take items in the collection while the given condition is met.
Parameters
- $value mixed
tapEach ( callable $callback ) : static
Pass each item in the collection to the given callback, lazily.
Parameters
- $callback callable
undot ( ) : static
Convert a flatten "dot" notation array into an expanded array.
unique ( $key , $strict ) : static
Return only unique items from the collection array.
Parameters
- $key string|callable|null
- $strict bool
values ( ) : static
Reset the keys on the underlying array.
zip ( $items ) : static
Zip the collection together with one or more arrays.
Parameters
- $items mixed
pad ( $size , $value ) : static
Pad collection to the specified length with a value.
Parameters
- $size int
- $value mixed
count ( ) : int
Count the number of items in the collection.
makeIterator ( $source ) : Traversable
Make an iterator from the given source.
Parameters
- $source mixed
explodePluckParameters ( $value , $key ) : array
Explode the "value" and "key" arguments passed to "pluck".
Parameters
- $value string|array
- $key string|array|null
passthru ( $method , array $params ) : static
Pass this lazy collection through a method on the collection class.
Parameters
- $method string
- $params array
now ( ) : int
Get the current time.