Method |
Description |
|
__construct ( mixed $items = [] ) : void |
Create a new collection. |
|
__toString ( ) : string |
Convert the collection to its string representation. |
|
all ( ) : array |
Get all of the items in the collection. |
|
average ( callable | string | null $callback = null ) : mixed |
Alias for the "avg" method. |
|
avg ( callable | string | null $callback = null ) : mixed |
Get the average value of a given key. |
|
chunk ( integer $size ) : static |
Chunk the underlying collection array. |
|
collapse ( ) : static |
Collapse the collection of items into a single array. |
|
combine ( mixed $values ) : static |
Create a collection by using this collection for keys and another for its values. |
|
contains ( mixed $key, mixed $value = null ) : boolean |
Determine if an item exists in the collection. |
|
containsStrict ( mixed $key, mixed $value = null ) : boolean |
Determine if an item exists in the collection using strict comparison. |
|
count ( ) : integer |
Count the number of items in the collection. |
|
diff ( mixed $items ) : static |
Get the items in the collection that are not present in the given items. |
|
diffKeys ( mixed $items ) : static |
Get the items in the collection whose keys are not present in the given items. |
|
each ( callable $callback ) |
Execute a callback over each item. |
|
every ( integer $step, integer $offset ) : static |
Create a new collection consisting of every n-th element. |
|
except ( mixed $keys ) : static |
Get all items except for those with the specified keys. |
|
filter ( callable $callback = null ) : static |
Run a filter over each of the items. |
|
first ( callable $callback = null, mixed $default = null ) : mixed |
Get the first item from the collection. |
|
flatMap ( callable $callback ) : static |
Map a collection and flatten the result by a single level. |
|
flatten ( integer $depth = INF ) : static |
Get a flattened array of the items in the collection. |
|
flip ( ) : static |
Flip the items in the collection. |
|
forPage ( integer $page, integer $perPage ) : static |
"Paginate" the collection by slicing it into a smaller collection. |
|
forget ( string | array $keys ) |
Remove an item from the collection by key. |
|
get ( mixed $key, mixed $default = null ) : mixed |
Get an item from the collection by key. |
|
getCachingIterator ( integer $flags = CachingIterator::CALL_TOSTRING ) : CachingIterator |
Get a CachingIterator instance. |
|
getIterator ( ) : ArrayIterator |
Get an iterator for the items. |
|
groupBy ( callable | string $groupBy, boolean $preserveKeys = false ) : static |
Group an associative array by a field or using a callback. |
|
has ( mixed $key ) : boolean |
Determine if an item exists in the collection by key. |
|
implode ( string $value, string $glue = null ) : string |
Concatenate values of a given key as a string. |
|
intersect ( mixed $items ) : static |
Intersect the collection with the given items. |
|
isEmpty ( ) : boolean |
Determine if the collection is empty or not. |
|
jsonSerialize ( ) : array |
Convert the object into something JSON serializable. |
|
keyBy ( callable | string $keyBy ) : static |
Key an associative array by a field or using a callback. |
|
keys ( ) : static |
Get the keys of the collection items. |
|
last ( callable $callback = null, mixed $default = null ) : mixed |
Get the last item from the collection. |
|
make ( mixed $items = [] ) : static |
Create a new collection instance if the value isn't one already. |
|
map ( callable $callback ) : static |
Run a map over each of the items. |
|
mapWithKeys ( callable $callback ) : static |
Run an associative map over each of the items. |
|
max ( callable | string | null $callback = null ) : mixed |
Get the max value of a given key. |
|
median ( null $key = null ) : mixed | null |
Get the median of a given key. |
|
merge ( mixed $items ) : static |
Merge the collection with the given items. |
|
min ( callable | string | null $callback = null ) : mixed |
Get the min value of a given key. |
|
mode ( null $key = null ) : array |
Get the mode of a given key. |
|
offsetExists ( mixed $key ) : boolean |
Determine if an item exists at an offset. |
|
offsetGet ( mixed $key ) : mixed |
Get an item at a given offset. |
|
offsetSet ( mixed $key, mixed $value ) : void |
Set the item at a given offset. |
|
offsetUnset ( string $key ) : void |
Unset the item at a given offset. |
|
only ( mixed $keys ) : static |
Get the items with the specified keys. |
|
pipe ( callable $callback ) : mixed |
Pass the collection to the given callback and return the result. |
|
pluck ( string $value, string | null $key = null ) : static |
Get the values of a given key. |
|
pop ( ) : mixed |
Get and remove the last item from the collection. |
|
prepend ( mixed $value, mixed $key = null ) |
Push an item onto the beginning of the collection. |
|
pull ( mixed $key, mixed $default = null ) : mixed |
Get and remove an item from the collection. |
|
push ( mixed $value ) |
Push an item onto the end of the collection. |
|
put ( mixed $key, mixed $value ) |
Put an item in the collection by key. |
|
random ( integer $amount = 1 ) : mixed |
Get one or more items randomly from the collection. |
|
reduce ( callable $callback, mixed $initial = null ) : mixed |
Reduce the collection to a single value. |
|
reject ( callable | mixed $callback ) : static |
Create a collection of all elements that do not pass a given truth test. |
|
reverse ( ) : static |
Reverse items order. |
|
search ( mixed $value, boolean $strict = false ) : mixed |
Search the collection for a given value and return the corresponding key if successful. |
|
shift ( ) : mixed |
Get and remove the first item from the collection. |
|
shuffle ( integer $seed = null ) : static |
Shuffle the items in the collection. |
|
slice ( integer $offset, integer $length = null ) : static |
Slice the underlying collection array. |
|
sort ( callable $callback = null ) : static |
Sort through each item with a callback. |
|
sortBy ( callable | string $callback, integer $options = SORT_REGULAR, boolean $descending = false ) : static |
Sort the collection using the given callback. |
|
sortByDesc ( callable | string $callback, integer $options = SORT_REGULAR ) : static |
Sort the collection in descending order using the given callback. |
|
splice ( integer $offset, integer | null $length = null, mixed $replacement = [] ) : static |
Splice a portion of the underlying collection array. |
|
split ( integer $numberOfGroups ) : static |
Split a collection into a certain number of groups. |
|
sum ( callable | string | null $callback = null ) : mixed |
Get the sum of the given values. |
|
take ( integer $limit ) : static |
Take the first or last {$limit} items. |
|
toArray ( ) : array |
Get the collection of items as a plain array. |
|
toBase ( ) : Collection |
Get a base Support collection instance from this collection. |
|
toJson ( integer $options ) : string |
Get the collection of items as JSON. |
|
transform ( callable $callback ) |
Transform each item in the collection using a callback. |
|
union ( mixed $items ) : static |
Union the collection with the given items. |
|
unique ( string | callable | null $key = null, boolean $strict = false ) : static |
Return only unique items from the collection array. |
|
uniqueStrict ( string | callable | null $key = null ) : static |
Return only unique items from the collection array using strict comparison. |
|
values ( ) : static |
Reset the keys on the underlying array. |
|
where ( string $key, mixed $operator, mixed $value = null ) : static |
Filter items by the given key value pair. |
|
whereIn ( string $key, mixed $values, boolean $strict = false ) : static |
Filter items by the given key value pair. |
|
whereInStrict ( string $key, mixed $values ) : static |
Filter items by the given key value pair using strict comparison. |
|
whereStrict ( string $key, mixed $value ) : static |
Filter items by the given key value pair using strict comparison. |
|
zip ( $items ) : static |
Zip the collection together with one or more arrays. |
|