EnumeratesValues
trait EnumeratesValues (View source)
Properties
static protected array | $proxies | The methods that can be proxied. |
|
HigherOrderCollectionProxy read-only | $average | ||
HigherOrderCollectionProxy read-only | $avg | ||
HigherOrderCollectionProxy read-only | $contains | ||
HigherOrderCollectionProxy read-only | $each | ||
HigherOrderCollectionProxy read-only | $every | ||
HigherOrderCollectionProxy read-only | $filter | ||
HigherOrderCollectionProxy read-only | $first | ||
HigherOrderCollectionProxy read-only | $flatMap | ||
HigherOrderCollectionProxy read-only | $groupBy | ||
HigherOrderCollectionProxy read-only | $keyBy | ||
HigherOrderCollectionProxy read-only | $map | ||
HigherOrderCollectionProxy read-only | $max | ||
HigherOrderCollectionProxy read-only | $min | ||
HigherOrderCollectionProxy read-only | $partition | ||
HigherOrderCollectionProxy read-only | $reject | ||
HigherOrderCollectionProxy read-only | $some | ||
HigherOrderCollectionProxy read-only | $sortBy | ||
HigherOrderCollectionProxy read-only | $sortByDesc | ||
HigherOrderCollectionProxy read-only | $sum | ||
HigherOrderCollectionProxy read-only | $unique | ||
HigherOrderCollectionProxy read-only | $until |
Methods
Create a new collection instance if the value isn't one already.
Wrap the given value in a collection if applicable.
Get the underlying items from the given collection if applicable.
Alias for the "avg" method.
Alias for the "contains" method.
Determine if an item exists, using strict comparison.
Dump the items and end the script.
Dump the items.
Execute a callback over each item.
Execute a callback over each nested chunk of items.
Determine if all items pass the given truth test.
Get the first item by the given key value pair.
Determine if the collection is not empty.
Run a map over each nested chunk of items.
Run a grouping map over the items.
Map a collection and flatten the result by a single level.
Map the values into a new class.
Get the min value of a given key.
Get the max value of a given key.
"Paginate" the collection by slicing it into a smaller collection.
Partition the collection into two arrays using the given callback or key.
Get the sum of the given values.
Apply the callback if the value is truthy.
Apply the callback if the collection is empty.
Apply the callback if the collection is not empty.
Apply the callback if the value is falsy.
Apply the callback unless the collection is empty.
Apply the callback unless the collection is not empty.
Filter items by the given key value pair.
Filter items where the given key is not null.
Filter items where the given key is null.
Filter items by the given key value pair using strict comparison.
Filter items by the given key value pair.
Filter items by the given key value pair using strict comparison.
Filter items such that the value of the given key is between the given values.
Filter items such that the value of the given key is not between the given values.
Filter items by the given key value pair.
Filter items by the given key value pair using strict comparison.
Filter the items, removing any items that don't match the given type.
Pass the collection to the given callback and return the result.
Pass the collection to the given callback and then return it.
Create a collection of all elements that do not pass a given truth test.
Return only unique items from the collection array.
Return only unique items from the collection array using strict comparison.
Collect the values into a collection.
Get the collection of items as a plain array.
Convert the object into something JSON serializable.
Get the collection of items as JSON.
Get a CachingIterator instance.
Convert the collection to its string representation.
Add a method to the list of proxied methods.
Dynamically access collection proxies.
Results array of items from Collection or Arrayable.
Get an operator checker callback.
Determine if the given value is callable, but not a string.
Get a value retrieving callback.
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.