trait Illuminate / Support / Traits / EnumeratesValues
You are viewing an older version of the documentation. For the latest, please visit master documentation.

EnumeratesValues

Properties

protected

$escapeWhenCastingToString bool

Indicates that the object's string representation should be escaped when __toString is invoked.

Default: false
protected static

$proxies string[]

The methods that can be proxied.

Default: array

Methods

public static

make ( $items ) : static

Create a new collection instance if the value isn't one already.

Parameters

  • $items mixed
public static

wrap ( $value ) : static

Wrap the given value in a collection if applicable.

Parameters

  • $value mixed
public static

unwrap ( $value ) : array

Get the underlying items from the given collection if applicable.

Parameters

  • $value array|static
public static

empty ( ) : static

Create a new instance with no items.

public static

times ( $number , callable $callback ) : static

Create a new collection by invoking the callback a given amount of times.

Parameters

  • $number int
  • $callback callable|null
public

average ( $callback ) : mixed

Alias for the "avg" method.

Parameters

  • $callback callable|string|null
public

some ( $key , $operator , $value ) : bool

Alias for the "contains" method.

Parameters

  • $key mixed
  • $operator mixed
  • $value mixed
public

containsStrict ( $key , $value ) : bool

Determine if an item exists, using strict comparison.

Parameters

  • $key mixed
  • $value mixed
public

dd ( $args ) : void

Dump the items and end the script.

Parameters

  • $args mixed
public

dump ( ) : $this

Dump the items.

public

each ( callable $callback ) : $this

Execute a callback over each item.

Parameters

  • $callback callable
public

eachSpread ( callable $callback ) : static

Execute a callback over each nested chunk of items.

Parameters

  • $callback callable
public

every ( $key , $operator , $value ) : bool

Determine if all items pass the given truth test.

Parameters

  • $key string|callable
  • $operator mixed
  • $value mixed
public

firstWhere ( $key , $operator , $value ) : mixed

Get the first item by the given key value pair.

Parameters

  • $key string
  • $operator mixed
  • $value mixed
public

isNotEmpty ( ) : bool

Determine if the collection is not empty.

public

mapSpread ( callable $callback ) : static

Run a map over each nested chunk of items.

Parameters

  • $callback callable
public

mapToGroups ( callable $callback ) : static

Run a grouping map over the items.

Parameters

  • $callback callable
public

flatMap ( callable $callback ) : static

Map a collection and flatten the result by a single level.

Parameters

  • $callback callable
public

mapInto ( $class ) : static

Map the values into a new class.

Parameters

  • $class string
public

min ( $callback ) : mixed

Get the min value of a given key.

Parameters

  • $callback callable|string|null
public

max ( $callback ) : mixed

Get the max value of a given key.

Parameters

  • $callback callable|string|null
public

forPage ( $page , $perPage ) : static

"Paginate" the collection by slicing it into a smaller collection.

Parameters

  • $page int
  • $perPage int
public

partition ( $key , $operator , $value ) : static

Partition the collection into two arrays using the given callback or key.

Parameters

  • $key callable|string
  • $operator mixed
  • $value mixed
public

sum ( $callback ) : mixed

Get the sum of the given values.

Parameters

  • $callback callable|string|null
public

when ( $value , callable $callback , callable $default ) : static|mixed

Apply the callback if the value is truthy.

Parameters

  • $value bool|mixed
  • $callback callable|null
  • $default callable|null
public

whenEmpty ( callable $callback , callable $default ) : static|mixed

Apply the callback if the collection is empty.

Parameters

  • $callback callable
  • $default callable|null
public

whenNotEmpty ( callable $callback , callable $default ) : static|mixed

Apply the callback if the collection is not empty.

Parameters

  • $callback callable
  • $default callable|null
public

unless ( $value , callable $callback , callable $default ) : static|mixed

Apply the callback if the value is falsy.

Parameters

  • $value bool
  • $callback callable
  • $default callable|null
public

unlessEmpty ( callable $callback , callable $default ) : static|mixed

Apply the callback unless the collection is empty.

Parameters

  • $callback callable
  • $default callable|null
public

unlessNotEmpty ( callable $callback , callable $default ) : static|mixed

Apply the callback unless the collection is not empty.

Parameters

  • $callback callable
  • $default callable|null
public

where ( $key , $operator , $value ) : static

Filter items by the given key value pair.

Parameters

  • $key string
  • $operator mixed
  • $value mixed
public

whereNull ( $key ) : static

Filter items where the value for the given key is null.

Parameters

  • $key string|null
public

whereNotNull ( $key ) : static

Filter items where the value for the given key is not null.

Parameters

  • $key string|null
public

whereStrict ( $key , $value ) : static

Filter items by the given key value pair using strict comparison.

Parameters

  • $key string
  • $value mixed
public

whereIn ( $key , $values , $strict ) : static

Filter items by the given key value pair.

Parameters

  • $key string
  • $values mixed
  • $strict bool
public

whereInStrict ( $key , $values ) : static

Filter items by the given key value pair using strict comparison.

Parameters

  • $key string
  • $values mixed
public

whereBetween ( $key , $values ) : static

Filter items such that the value of the given key is between the given values.

Parameters

  • $key string
  • $values array
public

whereNotBetween ( $key , $values ) : static

Filter items such that the value of the given key is not between the given values.

Parameters

  • $key string
  • $values array
public

whereNotIn ( $key , $values , $strict ) : static

Filter items by the given key value pair.

Parameters

  • $key string
  • $values mixed
  • $strict bool
public

whereNotInStrict ( $key , $values ) : static

Filter items by the given key value pair using strict comparison.

Parameters

  • $key string
  • $values mixed
public

whereInstanceOf ( $type ) : static

Filter the items, removing any items that don't match the given type(s).

Parameters

  • $type string|string[]
public

pipe ( callable $callback ) : mixed

Pass the collection to the given callback and return the result.

Parameters

  • $callback callable
public

pipeInto ( $class ) : mixed

Pass the collection into a new class.

Parameters

  • $class string
public

pipeThrough ( $pipes ) : mixed

Pass the collection through a series of callable pipes and return the result.

Parameters

  • $pipes callable[]
public

tap ( callable $callback ) : $this

Pass the collection to the given callback and then return it.

Parameters

  • $callback callable
public

reduce ( callable $callback , $initial ) : mixed

Reduce the collection to a single value.

Parameters

  • $callback callable
  • $initial mixed
deprecated public

reduceMany ( callable $callback , $initial ) : array

Reduce the collection to multiple aggregate values.

Parameters

  • $callback callable
  • $initial mixed
public

reduceSpread ( callable $callback , $initial ) : array

Reduce the collection to multiple aggregate values.

Parameters

  • $callback callable
  • $initial mixed
public

reduceWithKeys ( callable $callback , $initial ) : mixed

Reduce an associative collection to a single value.

Parameters

  • $callback callable
  • $initial mixed
public

reject ( $callback ) : static

Create a collection of all elements that do not pass a given truth test.

Parameters

  • $callback callable|mixed
public

uniqueStrict ( $key ) : static

Return only unique items from the collection array using strict comparison.

Parameters

  • $key string|callable|null
public

collect ( ) : Collection

Collect the values into a collection.

public

toArray ( ) : array

Get the collection of items as a plain array.

public

jsonSerialize ( ) : array

Convert the object into something JSON serializable.

public

toJson ( $options ) : string

Get the collection of items as JSON.

Parameters

  • $options int
public

getCachingIterator ( $flags ) : CachingIterator

Get a CachingIterator instance.

Parameters

  • $flags int
public

__toString ( ) : string

Convert the collection to its string representation.

public

escapeWhenCastingToString ( $escape ) : $this

Indicate that the model's string representation should be escaped when __toString is invoked.

Parameters

  • $escape bool
public static

proxy ( $method ) : void

Add a method to the list of proxied methods.

Parameters

  • $method string
public

__get ( $key ) : mixed

Dynamically access collection proxies.

Parameters

  • $key string
protected

getArrayableItems ( $items ) : array

Results array of items from Collection or Arrayable.

Parameters

  • $items mixed
protected

operatorForWhere ( $key , $operator , $value ) : Closure

Get an operator checker callback.

Parameters

  • $key string
  • $operator string|null
  • $value mixed
protected

useAsCallable ( $value ) : bool

Determine if the given value is callable, but not a string.

Parameters

  • $value mixed
protected

valueRetriever ( $value ) : callable

Get a value retrieving callback.

Parameters

  • $value callable|string|null
protected

equality ( $value ) : Closure

Make a function to check an item's equality.

Parameters

  • $value mixed
protected

negate ( Closure $callback ) : Closure

Make a function using another function, by negating its result.

Parameters

protected

identity ( ) : Closure

Make a function that returns what's passed to it.