EnumeratesValues
trait EnumeratesValues (View source)
Properties
static protected array | $proxies | The methods that can be proxied. |
Methods
static EnumeratesValues | make(mixed $items = []) Create a new collection instance if the value isn't one already. | |
static EnumeratesValues | wrap(mixed $value) Wrap the given value in a collection if applicable. | |
static array | unwrap(array|EnumeratesValues $value) Get the underlying items from the given collection if applicable. | |
mixed | average(callable|string|null $callback = null) Alias for the "avg" method. | |
bool | some(mixed $key, mixed $operator = null, mixed $value = null) Alias for the "contains" method. | |
bool | containsStrict(mixed $key, mixed $value = null) Determine if an item exists, using strict comparison. | |
void | dd(mixed ...$args) Dump the items and end the script. | |
$this | dump() Dump the items. | |
$this | each(callable $callback) Execute a callback over each item. | |
EnumeratesValues | eachSpread(callable $callback) Execute a callback over each nested chunk of items. | |
bool | every(string|callable $key, mixed $operator = null, mixed $value = null) Determine if all items pass the given truth test. | |
mixed | firstWhere(string $key, mixed $operator = null, mixed $value = null) Get the first item by the given key value pair. | |
bool | isNotEmpty() Determine if the collection is not empty. | |
EnumeratesValues | mapSpread(callable $callback) Run a map over each nested chunk of items. | |
EnumeratesValues | mapToGroups(callable $callback) Run a grouping map over the items. | |
EnumeratesValues | flatMap(callable $callback) Map a collection and flatten the result by a single level. | |
EnumeratesValues | mapInto(string $class) Map the values into a new class. | |
mixed | min(callable|string|null $callback = null) Get the min value of a given key. | |
mixed | max(callable|string|null $callback = null) Get the max value of a given key. | |
EnumeratesValues | forPage(int $page, int $perPage) "Paginate" the collection by slicing it into a smaller collection. | |
EnumeratesValues | partition(callable|string $key, mixed $operator = null, mixed $value = null) Partition the collection into two arrays using the given callback or key. | |
mixed | sum(callable|string|null $callback = null) Get the sum of the given values. | |
EnumeratesValues|mixed | when(bool|mixed $value, callable $callback = null, callable $default = null) Apply the callback if the value is truthy. | |
EnumeratesValues|mixed | whenEmpty(callable $callback, callable $default = null) Apply the callback if the collection is empty. | |
EnumeratesValues|mixed | whenNotEmpty(callable $callback, callable $default = null) Apply the callback if the collection is not empty. | |
EnumeratesValues|mixed | unless(bool $value, callable $callback, callable $default = null) Apply the callback if the value is falsy. | |
EnumeratesValues|mixed | unlessEmpty(callable $callback, callable $default = null) Apply the callback unless the collection is empty. | |
EnumeratesValues|mixed | unlessNotEmpty(callable $callback, callable $default = null) Apply the callback unless the collection is not empty. | |
EnumeratesValues | where(string $key, mixed $operator = null, mixed $value = null) Filter items by the given key value pair. | |
EnumeratesValues | whereNull(string|null $key = null) Filter items where the given key is not null. | |
EnumeratesValues | whereNotNull(string|null $key = null) Filter items where the given key is null. | |
EnumeratesValues | whereStrict(string $key, mixed $value) Filter items by the given key value pair using strict comparison. | |
EnumeratesValues | whereIn(string $key, mixed $values, bool $strict = false) Filter items by the given key value pair. | |
EnumeratesValues | whereInStrict(string $key, mixed $values) Filter items by the given key value pair using strict comparison. | |
EnumeratesValues | whereBetween(string $key, array $values) Filter items such that the value of the given key is between the given values. | |
EnumeratesValues | whereNotBetween(string $key, array $values) Filter items such that the value of the given key is not between the given values. | |
EnumeratesValues | whereNotIn(string $key, mixed $values, bool $strict = false) Filter items by the given key value pair. | |
EnumeratesValues | whereNotInStrict(string $key, mixed $values) Filter items by the given key value pair using strict comparison. | |
EnumeratesValues | whereInstanceOf(string $type) Filter the items, removing any items that don't match the given type. | |
mixed | pipe(callable $callback) Pass the collection to the given callback and return the result. | |
$this | tap(callable $callback) Pass the collection to the given callback and then return it. | |
EnumeratesValues | reject(callable|mixed $callback = true) Create a collection of all elements that do not pass a given truth test. | |
EnumeratesValues | unique(string|callable|null $key = null, bool $strict = false) Return only unique items from the collection array. | |
EnumeratesValues | uniqueStrict(string|callable|null $key = null) Return only unique items from the collection array using strict comparison. | |
EnumeratesValues | until(mixed $value) deprecated Take items in the collection until the given condition is met. | |
Collection | collect() Collect the values into a collection. | |
array | toArray() Get the collection of items as a plain array. | |
array | jsonSerialize() Convert the object into something JSON serializable. | |
string | toJson(int $options = 0) Get the collection of items as JSON. | |
CachingIterator | getCachingIterator(int $flags = CachingIterator::CALL_TOSTRING) Get a CachingIterator instance. | |
string | __toString() Convert the collection to its string representation. | |
static void | proxy(string $method) Add a method to the list of proxied methods. | |
mixed | __get(string $key) Dynamically access collection proxies. | |
array | getArrayableItems(mixed $items) Results array of items from Collection or Arrayable. | |
Closure | operatorForWhere(string $key, string|null $operator = null, mixed $value = null) Get an operator checker callback. | |
bool | useAsCallable(mixed $value) Determine if the given value is callable, but not a string. | |
callable | valueRetriever(callable|string|null $value) Get a value retrieving callback. | |
Closure | equality(mixed $value) Make a function to check an item's equality. | |
Closure | negate(Closure $callback) Make a function using another function, by negating its result. | |
Closure | identity() Make a function that returns what's passed to it. |
Details
static EnumeratesValues make(mixed $items = [])
Create a new collection instance if the value isn't one already.
static EnumeratesValues wrap(mixed $value)
Wrap the given value in a collection if applicable.
static array unwrap(array|EnumeratesValues $value)
Get the underlying items from the given collection if applicable.
mixed average(callable|string|null $callback = null)
Alias for the "avg" method.
bool some(mixed $key, mixed $operator = null, mixed $value = null)
Alias for the "contains" method.
bool containsStrict(mixed $key, mixed $value = null)
Determine if an item exists, using strict comparison.
void dd(mixed ...$args)
Dump the items and end the script.
$this dump()
Dump the items.
$this each(callable $callback)
Execute a callback over each item.
EnumeratesValues eachSpread(callable $callback)
Execute a callback over each nested chunk of items.
bool every(string|callable $key, mixed $operator = null, mixed $value = null)
Determine if all items pass the given truth test.
mixed firstWhere(string $key, mixed $operator = null, mixed $value = null)
Get the first item by the given key value pair.
bool isNotEmpty()
Determine if the collection is not empty.
EnumeratesValues mapSpread(callable $callback)
Run a map over each nested chunk of items.
EnumeratesValues mapToGroups(callable $callback)
Run a grouping map over the items.
The callback should return an associative array with a single key/value pair.
EnumeratesValues flatMap(callable $callback)
Map a collection and flatten the result by a single level.
EnumeratesValues mapInto(string $class)
Map the values into a new class.
mixed min(callable|string|null $callback = null)
Get the min value of a given key.
mixed max(callable|string|null $callback = null)
Get the max value of a given key.
EnumeratesValues forPage(int $page, int $perPage)
"Paginate" the collection by slicing it into a smaller collection.
EnumeratesValues partition(callable|string $key, mixed $operator = null, mixed $value = null)
Partition the collection into two arrays using the given callback or key.
mixed sum(callable|string|null $callback = null)
Get the sum of the given values.
EnumeratesValues|mixed when(bool|mixed $value, callable $callback = null, callable $default = null)
Apply the callback if the value is truthy.
EnumeratesValues|mixed whenEmpty(callable $callback, callable $default = null)
Apply the callback if the collection is empty.
EnumeratesValues|mixed whenNotEmpty(callable $callback, callable $default = null)
Apply the callback if the collection is not empty.
EnumeratesValues|mixed unless(bool $value, callable $callback, callable $default = null)
Apply the callback if the value is falsy.
EnumeratesValues|mixed unlessEmpty(callable $callback, callable $default = null)
Apply the callback unless the collection is empty.
EnumeratesValues|mixed unlessNotEmpty(callable $callback, callable $default = null)
Apply the callback unless the collection is not empty.
EnumeratesValues where(string $key, mixed $operator = null, mixed $value = null)
Filter items by the given key value pair.
EnumeratesValues whereNull(string|null $key = null)
Filter items where the given key is not null.
EnumeratesValues whereNotNull(string|null $key = null)
Filter items where the given key is null.
EnumeratesValues whereStrict(string $key, mixed $value)
Filter items by the given key value pair using strict comparison.
EnumeratesValues whereIn(string $key, mixed $values, bool $strict = false)
Filter items by the given key value pair.
EnumeratesValues whereInStrict(string $key, mixed $values)
Filter items by the given key value pair using strict comparison.
EnumeratesValues whereBetween(string $key, array $values)
Filter items such that the value of the given key is between the given values.
EnumeratesValues whereNotBetween(string $key, array $values)
Filter items such that the value of the given key is not between the given values.
EnumeratesValues whereNotIn(string $key, mixed $values, bool $strict = false)
Filter items by the given key value pair.
EnumeratesValues whereNotInStrict(string $key, mixed $values)
Filter items by the given key value pair using strict comparison.
EnumeratesValues whereInstanceOf(string $type)
Filter the items, removing any items that don't match the given type.
mixed pipe(callable $callback)
Pass the collection to the given callback and return the result.
$this tap(callable $callback)
Pass the collection to the given callback and then return it.
EnumeratesValues reject(callable|mixed $callback = true)
Create a collection of all elements that do not pass a given truth test.
EnumeratesValues unique(string|callable|null $key = null, bool $strict = false)
Return only unique items from the collection array.
EnumeratesValues uniqueStrict(string|callable|null $key = null)
Return only unique items from the collection array using strict comparison.
EnumeratesValues until(mixed $value) deprecated
deprecated
Take items in the collection until the given condition is met.
This is an alias to the "takeUntil" method.
Collection collect()
Collect the values into a collection.
array toArray()
Get the collection of items as a plain array.
array jsonSerialize()
Convert the object into something JSON serializable.
string toJson(int $options = 0)
Get the collection of items as JSON.
CachingIterator getCachingIterator(int $flags = CachingIterator::CALL_TOSTRING)
Get a CachingIterator instance.
string __toString()
Convert the collection to its string representation.
static void proxy(string $method)
Add a method to the list of proxied methods.
mixed __get(string $key)
Dynamically access collection proxies.
protected array getArrayableItems(mixed $items)
Results array of items from Collection or Arrayable.
protected Closure operatorForWhere(string $key, string|null $operator = null, mixed $value = null)
Get an operator checker callback.
protected bool useAsCallable(mixed $value)
Determine if the given value is callable, but not a string.
protected callable valueRetriever(callable|string|null $value)
Get a value retrieving callback.
protected Closure equality(mixed $value)
Make a function to check an item's equality.
protected Closure negate(Closure $callback)
Make a function using another function, by negating its result.
protected Closure identity()
Make a function that returns what's passed to it.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/Support/Traits/EnumeratesValues.html