Overview

Namespaces

  • Composer
    • Autoload
  • Illuminate
    • Support
      • Contracts
      • Facades
  • Laravella
    • Crud
      • Exceptions
      • Facades
  • None
  • PHP

Classes

  • ClassLoader
  • Collection
  • Fluent
  • Manager
  • MessageBag
  • NamespacedItemResolver
  • Pluralizer
  • SerializableClosure
  • ServiceProvider
  • Str
  • Overview
  • Namespace
  • Class
  • Tree

Class Collection

Illuminate\Support\Collection implements ArrayAccess, Illuminate\Support\Contracts\ArrayableInterface, Countable, IteratorAggregate, Illuminate\Support\Contracts\JsonableInterface
Namespace: Illuminate\Support
Located at vendor/illuminate/support/Illuminate/Support/Collection.php
Methods summary
public
# __construct( array $items = array() )

Create a new collection.

Create a new collection.

Parameters

$items
array
$items
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

$items
mixed
$items

Returns

Illuminate\Support\Collection
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

$key
mixed
$key

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

$value
mixed
$value
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

$key
mixed
$key
public Illuminate\Support\Collection
# each( Closure $callback )

Execute a callback over each item.

Execute a callback over each item.

Parameters

$callback
Closure
$callback

Returns

Illuminate\Support\Collection
public array
# map( Closure $callback )

Run a map over each of the items.

Run a map over each of the items.

Parameters

$callback
Closure
$callback

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

$callback
Closure
$callback

Returns

Illuminate\Support\Collection
public Illuminate\Support\Collection
# sort( Closure $callback )

Sort through each item with a callback.

Sort through each item with a callback.

Parameters

$callback
Closure
$callback

Returns

Illuminate\Support\Collection
public Illuminate\Support\Collection
# sortBy( Closure $callback )

Sort the collection using the given Closure.

Sort the collection using the given Closure.

Parameters

$callback
Closure
$callback

Returns

Illuminate\Support\Collection
public Illuminate\Support\Collection
# reverse( )

Reverse items order.

Reverse items order.

Returns

Illuminate\Support\Collection
public Illuminate\Support\Collection
# values( )

Reset the keys on the underlying array.

Reset the keys on the underlying array.

Returns

Illuminate\Support\Collection
public Illuminate\Support\Collection
# fetch( string $key )

Fetch a nested element of the collection.

Fetch a nested element of the collection.

Parameters

$key
string
$key

Returns

Illuminate\Support\Collection
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

Illuminate\Support\Collection
public Illuminate\Support\Collection
# merge( Illuminate\Support\Collection|Illuminate\Support\Contracts\ArrayableInterface|array $items )

Merge items with the collection items.

Merge items with the collection items.

Parameters

$items
Illuminate\Support\Collection|Illuminate\Support\Contracts\ArrayableInterface|array

Returns

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

Illuminate\Support\Collection
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

Illuminate\Support\Contracts\ArrayableInterface::toArray()
public string
# toJson( integer $options = 0 )

Get the collection of items as JSON.

Get the collection of items as JSON.

Parameters

$options
integer
$options

Returns

string

Implementation of

Illuminate\Support\Contracts\JsonableInterface::toJson()
public ArrayIterator
# getIterator( )

Get an iterator for the items.

Get an iterator for the items.

Returns

ArrayIterator

Implementation of

IteratorAggregate::getIterator()
public integer
# count( )

Count the number of items in the collection.

Count the number of items in the collection.

Returns

integer

Implementation of

Countable::count()
public boolean
# offsetExists( mixed $key )

Determine if an item exists at an offset.

Determine if an item exists at an offset.

Parameters

$key
mixed
$key

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed
# offsetGet( mixed $key )

Get an item at a given offset.

Get an item at a given offset.

Parameters

$key
mixed
$key

Returns

mixed

Implementation of

ArrayAccess::offsetGet()
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

ArrayAccess::offsetSet()
public
# offsetUnset( string $key )

Unset the item at a given offset.

Unset the item at a given offset.

Parameters

$key
string
$key

Implementation of

ArrayAccess::offsetUnset()
public string
# __toString( )

Convert the collection to its string representation.

Convert the collection to its string representation.

Returns

string
Properties summary
protected array $items array()
#

The items contained in the collection.

The items contained in the collection.

crud API documentation generated by ApiGen 2.8.0