Method |
Description |
|
__construct ( array $items = [] ) |
Create a new collection. |
|
__toString ( ) : string |
Convert the collection to its string representation. |
|
all ( ) : array |
Get all of the items in the collection. |
|
collapse ( ) : Collection |
Collapse the collection items into a single array. |
|
count ( ) : integer |
Count the number of items in the collection. |
|
diff ( Collection | array $items ) : Collection |
Diff the collection with the given items. |
|
each ( Closure $callback ) : Collection |
Execute a callback over each item. |
|
fetch ( string $key ) : Collection |
Fetch a nested element of the collection. |
|
filter ( Closure $callback ) : Collection |
Run a filter over each of the items. |
|
first ( Closure $callback = null, mixed $default = null ) : mixed | null |
Get the first item from the collection. |
|
flatten ( ) : array |
Get a flattened array of the items in the collection. |
|
forget ( mixed $key ) : void |
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 ) : Collection |
Group an associative array by a field or Closure value. |
|
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 ( Collection | array $items ) : Collection |
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. |
|
last ( ) : mixed | null |
Get the last item from the collection. |
|
lists ( string $value, string $key = null ) : array |
Get an array with the values of a given key. |
|
make ( mixed $items ) : static |
Create a new collection instance if the value isn't one already. |
|
map ( Closure $callback ) : Collection |
Run a map over each of the items. |
|
merge ( Collection | array $items ) : Collection |
Merge the collection with the given items. |
|
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. |
|
pop ( ) : mixed | null |
Get and remove the last item from the collection. |
|
prepend ( mixed $value ) : void |
Push an item onto the beginning of the collection. |
|
push ( mixed $value ) : void |
Push an item onto the end of the collection. |
|
put ( mixed $key, mixed $value ) : void |
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. |
|
reset ( ) : Collection |
Resets the Collection (removes all items) |
|
reverse ( ) : Collection |
Reverse items order. |
|
shift ( ) : mixed | null |
Get and remove the first item from the collection. |
|
slice ( integer $offset, integer $length = null, boolean $preserveKeys = false ) : Collection |
Slice the underlying collection array. |
|
sort ( Closure $callback ) : Collection |
Sort through each item with a callback. |
|
sortBy ( Closure | string $callback, integer $options = SORT_REGULAR, boolean $descending = false ) : Collection |
Sort the collection using the given Closure. |
|
sortByDesc ( Closure | string $callback, integer $options = SORT_REGULAR ) : Collection |
Sort the collection in descending order using the given Closure. |
|
splice ( integer $offset, integer $length, mixed $replacement = [] ) : Collection |
Splice portion of the underlying collection array. |
|
sum ( Closure | string $callback ) : mixed |
Get the sum of the given values. |
|
take ( integer $limit = null ) : Collection |
Take the first or last {$limit} items. |
|
toArray ( ) : array |
Get the collection of items as a plain array. |
|
toJson ( integer $options ) : string |
Get the collection of items as JSON. |
|
transform ( callable $callback ) : Collection |
Transform each item in the collection using a callback. |
|
unique ( ) : Collection |
Return only unique items from the collection array. |
|
values ( ) : Collection |
Reset the keys on the underlying array. |
|