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
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
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
array
|
#
all( )
Get all of the items in the collection.
Get all of the items in the collection.
Returns
array
|
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|null
|
#
first( )
Get the first item from the collection.
Get the first item from the collection.
Returns
mixed|null
|
public
mixed|null
|
#
last( )
Get the last item from the collection.
Get the last item from the collection.
Returns
mixed|null
|
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
|
#
push( mixed $value )
Push an item onto the beginning of the collection.
Push an item onto the beginning of the collection.
Parameters
|
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
|
#
forget( mixed $key )
Remove an item from the collection by key.
Remove an item from the collection by key.
Parameters
|
public
Illuminate\Support\Collection
|
#
each( Closure $callback )
Execute a callback over each item.
Execute a callback over each item.
Parameters
Returns
|
public
array
|
#
map( Closure $callback )
Run a map over each of the items.
Run a map over each of the items.
Parameters
Returns
array
|
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
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 $callback )
Sort the collection using the given Closure.
Sort the collection using the given Closure.
Parameters
Returns
|
public
Illuminate\Support\Collection
|
#
reverse( )
Reverse items order.
Returns
|
public
Illuminate\Support\Collection
|
#
values( )
Reset the keys on the underlying array.
Reset the keys on the underlying array.
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
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
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
|
#
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
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
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
boolean
|
#
isEmpty( )
Determine if the collection is empty or not.
Determine if the collection is empty or not.
Returns
boolean
|
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
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
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
|