Methods summary
public
|
#
__construct( array $items = array() )
Create a new collection.
Parameters
|
public static
Illuminate\Support\Collection
|
#
make( mixed $items )
Create a new collection instance if the value isn't one already.
Create a new collection instance if the value isn't one already.
Parameters
Returns
|
public
array
|
#
all( )
Get all of the items in the collection.
Get all of the items in the collection.
Returns
array
|
public
Illuminate\Support\Collection
|
#
collapse( )
Collapse the collection items into a single array.
Collapse the collection items into a single array.
Returns
|
public
Illuminate\Support\Collection
|
|
public
Illuminate\Support\Collection
|
#
each( Closure $callback )
Execute a callback over each item.
Execute a callback over each item.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
fetch( string $key )
Fetch a nested element of the collection.
Fetch a nested element of the collection.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
filter( Closure $callback )
Run a filter over each of the items.
Run a filter over each of the items.
Parameters
Returns
|
public
mixed|null
|
#
first( Closure $callback = null, mixed $default = null )
Get the first item from the collection.
Get the first item from the collection.
Parameters
- $callback
Closure
$callback
- $default
mixed $default
Returns
mixed|null
|
public
array
|
#
flatten( )
Get a flattened array of the items in the collection.
Get a flattened array of the items in the collection.
Returns
array
|
public
|
#
forget( mixed $key )
Remove an item from the collection by key.
Remove an item from the collection by key.
Parameters
|
public
mixed
|
#
get( mixed $key, mixed $default = null )
Get an item from the collection by key.
Get an item from the collection by key.
Parameters
- $key
mixed $key
- $default
mixed $default
Returns
mixed
|
public
Illuminate\Support\Collection
|
#
groupBy( callable|string $groupBy )
Group an associative array by a field or Closure value.
Group an associative array by a field or Closure value.
Parameters
- $groupBy
callable|string $groupBy
Returns
|
public
boolean
|
#
has( mixed $key )
Determine if an item exists in the collection by key.
Determine if an item exists in the collection by key.
Parameters
Returns
boolean
|
public
string
|
#
implode( string $value, string $glue = null )
Concatenate values of a given key as a string.
Concatenate values of a given key as a string.
Parameters
- $value
string $value
- $glue
string $glue
Returns
string
|
public
Illuminate\Support\Collection
|
|
public
boolean
|
#
isEmpty( )
Determine if the collection is empty or not.
Determine if the collection is empty or not.
Returns
boolean
|
public
mixed|null
|
#
last( )
Get the last item from the collection.
Get the last item from the collection.
Returns
mixed|null
|
public
array
|
#
lists( string $value, string $key = null )
Get an array with the values of a given key.
Get an array with the values of a given key.
Parameters
- $value
string $value
- $key
string $key
Returns
array
|
public
Illuminate\Support\Collection
|
#
map( Closure $callback )
Run a map over each of the items.
Run a map over each of the items.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
|
public
mixed|null
|
#
pop( )
Get and remove the last item from the collection.
Get and remove the last item from the collection.
Returns
mixed|null
|
public
|
#
prepend( mixed $value )
Push an item onto the beginning of the collection.
Push an item onto the beginning of the collection.
Parameters
|
public
|
#
push( mixed $value )
Push an item onto the end of the collection.
Push an item onto the end of the collection.
Parameters
|
public
mixed
|
#
pull( mixed $key, mixed $default = null )
Pulls an item from the collection.
Pulls an item from the collection.
Parameters
- $key
mixed $key
- $default
mixed $default
Returns
mixed
|
public
|
#
put( mixed $key, mixed $value )
Put an item in the collection by key.
Put an item in the collection by key.
Parameters
- $key
mixed $key
- $value
mixed $value
|
public
mixed
|
#
random( integer $amount = 1 )
Get one or more items randomly from the collection.
Get one or more items randomly from the collection.
Parameters
Returns
mixed
|
public
mixed
|
#
reduce( callable $callback, mixed $initial = null )
Reduce the collection to a single value.
Reduce the collection to a single value.
Parameters
- $callback
callable $callback
- $initial
mixed $initial
Returns
mixed
|
public
Illuminate\Support\Collection
|
#
reject( Closure |mixed $callback )
Create a colleciton of all elements that do not pass a given truth test.
Create a colleciton of all elements that do not pass a given truth test.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
reverse( )
Reverse items order.
Returns
|
public
mixed
|
#
search( mixed $value, boolean $strict = false )
Search the collection for a given value and return the corresponding key if
successful.
Search the collection for a given value and return the corresponding key if
successful.
Parameters
- $value
mixed $value
- $strict
boolean $strict
Returns
mixed
|
public
mixed|null
|
#
shift( )
Get and remove the first item from the collection.
Get and remove the first item from the collection.
Returns
mixed|null
|
public
Illuminate\Support\Collection
|
#
slice( integer $offset, integer $length = null, boolean $preserveKeys = false )
Slice the underlying collection array.
Slice the underlying collection array.
Parameters
- $offset
integer $offset
- $length
integer $length
- $preserveKeys
boolean $preserveKeys
Returns
|
public
Illuminate\Support\Collection
|
#
chunk( integer $size, boolean $preserveKeys = false )
Chunk the underlying collection array.
Chunk the underlying collection array.
Parameters
- $size
integer $size
- $preserveKeys
boolean $preserveKeys
Returns
|
public
Illuminate\Support\Collection
|
#
sort( Closure $callback )
Sort through each item with a callback.
Sort through each item with a callback.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
sortBy( Closure |string $callback, integer $options = SORT_REGULAR, boolean $descending = false )
Sort the collection using the given Closure.
Sort the collection using the given Closure.
Parameters
- $callback
Closure |string
$callback
- $options
integer $options
- $descending
boolean $descending
Returns
|
public
Illuminate\Support\Collection
|
#
sortByDesc( Closure |string $callback, integer $options = SORT_REGULAR )
Sort the collection in descending order using the given Closure.
Sort the collection in descending order using the given Closure.
Parameters
- $callback
Closure |string
$callback
- $options
integer $options
Returns
|
public
Illuminate\Support\Collection
|
#
splice( integer $offset, integer $length = 0, mixed $replacement = array() )
Splice portion of the underlying collection array.
Splice portion of the underlying collection array.
Parameters
- $offset
integer $offset
- $length
integer $length
- $replacement
mixed $replacement
Returns
|
public
mixed
|
#
sum( Closure $callback )
Get the sum of the given values.
Get the sum of the given values.
Parameters
Returns
mixed
|
public
Illuminate\Support\Collection
|
#
take( integer $limit = null )
Take the first or last {$limit} items.
Take the first or last {$limit} items.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
transform( Closure $callback )
Transform each item in the collection using a callback.
Transform each item in the collection using a callback.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
unique( )
Return only unique items from the collection array.
Return only unique items from the collection array.
Returns
|
public
Illuminate\Support\Collection
|
#
values( )
Reset the keys on the underlying array.
Reset the keys on the underlying array.
Returns
|
protected
Closure
|
#
valueRetriever( string $value )
Get a value retrieving callback.
Get a value retrieving callback.
Parameters
Returns
|
public
array
|
#
toArray( )
Get the collection of items as a plain array.
Get the collection of items as a plain array.
Returns
array
Implementation of
|
public
array
|
#
jsonSerialize( )
Convert the object into something JSON serializable.
Convert the object into something JSON serializable.
Returns
array
Implementation of
|
public
string
|
#
toJson( integer $options = 0 )
Get the collection of items as JSON.
Get the collection of items as JSON.
Parameters
Returns
string
Implementation of
|
public
ArrayIterator
|
#
getIterator( )
Get an iterator for the items.
Get an iterator for the items.
Returns
Implementation of
|
public
CachingIterator
|
#
getCachingIterator( mixed $flags = Illuminate\Support\CachingIterator::CALL_TOSTRING )
Get a CachingIterator instance.
Get a CachingIterator instance.
Returns
|
public
integer
|
#
count( )
Count the number of items in the collection.
Count the number of items in the collection.
Returns
integer
Implementation of
|
public
boolean
|
#
offsetExists( mixed $key )
Determine if an item exists at an offset.
Determine if an item exists at an offset.
Parameters
Returns
boolean
Implementation of
|
public
mixed
|
#
offsetGet( mixed $key )
Get an item at a given offset.
Get an item at a given offset.
Parameters
Returns
mixed
Implementation of
|
public
|
#
offsetSet( mixed $key, mixed $value )
Set the item at a given offset.
Set the item at a given offset.
Parameters
- $key
mixed $key
- $value
mixed $value
Implementation of
|
public
|
#
offsetUnset( string $key )
Unset the item at a given offset.
Unset the item at a given offset.
Parameters
Implementation of
|
public
string
|
#
__toString( )
Convert the collection to its string representation.
Convert the collection to its string representation.
Returns
string
|
protected
array
|
|