Methods |
public
|
__construct(mixed $items = []): void
Create a new collection.
|
#
|
public
static
|
range(int $from, int $to): static
Create a collection with the given range.
Create a collection with the given range.
Implements
|
#
|
public
|
all(): array
Get all of the items in the collection.
Get all of the items in the collection.
Implements
|
#
|
public
|
lazy(): LazyCollection
Get a lazy collection for the items in this collection.
Get a lazy collection for the items in this collection.
|
#
|
public
|
avg(callable|string|null $callback = null): mixed
Get the average value of a given key.
Get the average value of a given key.
Implements
|
#
|
public
|
median(string|array|null $key = null): mixed
Get the median of a given key.
Get the median of a given key.
Implements
|
#
|
public
|
mode(string|array|null $key = null): array|null
Get the mode of a given key.
Get the mode of a given key.
Implements
|
#
|
public
|
collapse(): static
Collapse the collection of items into a single array.
Collapse the collection of items into a single array.
Overriden by
Implements
|
#
|
public
|
contains(mixed $key, mixed $operator = null, mixed $value = null): bool
Determine if an item exists in the collection.
Determine if an item exists in the collection.
Overriden by
Implements
|
#
|
public
|
doesntContain(mixed $key, mixed $operator = null, mixed $value = null): bool
Determine if an item is not contained in the collection.
Determine if an item is not contained in the collection.
|
#
|
public
|
crossJoin(mixed ...$lists): static
Cross join with the given lists, returning all possible permutations.
Cross join with the given lists, returning all possible permutations.
Implements
|
#
|
public
|
diff(mixed $items): static
Get the items in the collection that are not present in the given items.
Get the items in the collection that are not present in the given items.
Overriden by
Implements
|
#
|
public
|
diffUsing(mixed $items, callable $callback): static
Get the items in the collection that are not present in the given items, using the callback.
Get the items in the collection that are not present in the given items, using the callback.
Implements
|
#
|
public
|
diffAssoc(mixed $items): static
Get the items in the collection whose keys and values are not present in the given items.
Get the items in the collection whose keys and values are not present in the given items.
Implements
|
#
|
public
|
diffAssocUsing(mixed $items, callable $callback): static
Get the items in the collection whose keys and values are not present in the given items, using the callback.
Get the items in the collection whose keys and values are not present in the given items, using the callback.
Implements
|
#
|
public
|
diffKeys(mixed $items): static
Get the items in the collection whose keys are not present in the given items.
Get the items in the collection whose keys are not present in the given items.
Implements
|
#
|
public
|
diffKeysUsing(mixed $items, callable $callback): static
Get the items in the collection whose keys are not present in the given items, using the callback.
Get the items in the collection whose keys are not present in the given items, using the callback.
Implements
|
#
|
public
|
duplicates(callable|string|null $callback = null, bool $strict = false): static
Retrieve duplicate items from the collection.
Retrieve duplicate items from the collection.
Implements
|
#
|
public
|
duplicatesStrict(callable|string|null $callback = null): static
Retrieve duplicate items from the collection using strict comparison.
Retrieve duplicate items from the collection using strict comparison.
Implements
|
#
|
public
|
except(Collection|mixed $keys): static
Get all items except for those with the specified keys.
Get all items except for those with the specified keys.
Overriden by
Implements
|
#
|
public
|
filter(callable|null $callback = null): static
Run a filter over each of the items.
Run a filter over each of the items.
Implements
|
#
|
public
|
first(callable|null $callback = null, mixed $default = null): mixed
Get the first item from the collection passing the given truth test.
Get the first item from the collection passing the given truth test.
Implements
|
#
|
public
|
flatten(int $depth = INF): static
Get a flattened array of the items in the collection.
Get a flattened array of the items in the collection.
Overriden by
Implements
|
#
|
public
|
flip(): static
Flip the items in the collection.
Flip the items in the collection.
Overriden by
Implements
|
#
|
public
|
forget(string|int|array $keys): $this
Remove an item from the collection by key.
Remove an item from the collection by key.
|
#
|
public
|
get(mixed $key, mixed $default = null): mixed
Get an item from the collection by key.
Get an item from the collection by key.
Implements
|
#
|
public
|
getOrPut(mixed $key, mixed $value): mixed
Get an item from the collection by key or add it to collection if it does not exist.
Get an item from the collection by key or add it to collection if it does not exist.
|
#
|
public
|
groupBy(array|callable|string $groupBy, bool $preserveKeys = false): static
Group an associative array by a field or using a callback.
Group an associative array by a field or using a callback.
Implements
|
#
|
public
|
keyBy(callable|string $keyBy): static
Key an associative array by a field or using a callback.
Key an associative array by a field or using a callback.
Implements
|
#
|
public
|
has(mixed $key): bool
Determine if an item exists in the collection by key.
Determine if an item exists in the collection by key.
Implements
|
#
|
public
|
hasAny(mixed $key): bool
Determine if any of the keys exist in the collection.
Determine if any of the keys exist in the collection.
|
#
|
public
|
implode(string $value, string|null $glue = null): string
Concatenate values of a given key as a string.
Concatenate values of a given key as a string.
Implements
|
#
|
public
|
intersect(mixed $items): static
Intersect the collection with the given items.
Intersect the collection with the given items.
Overriden by
Implements
|
#
|
public
|
intersectByKeys(mixed $items): static
Intersect the collection with the given items by key.
Intersect the collection with the given items by key.
Implements
|
#
|
public
|
isEmpty(): bool
Determine if the collection is empty or not.
Determine if the collection is empty or not.
Implements
|
#
|
public
|
containsOneItem(): bool
Determine if the collection contains a single item.
Determine if the collection contains a single item.
|
#
|
public
|
join(string $glue, string $finalGlue = ''): string
Join all items from the collection using a string. The final items can use a separate glue string.
Join all items from the collection using a string. The final items can use a separate glue string.
Implements
|
#
|
public
|
keys(): static
Get the keys of the collection items.
Get the keys of the collection items.
Overriden by
Implements
|
#
|
public
|
last(callable|null $callback = null, mixed $default = null): mixed
Get the last item from the collection.
Get the last item from the collection.
Implements
|
#
|
public
|
pluck(string|array|int|null $value, string|null $key = null): static
Get the values of a given key.
Get the values of a given key.
Overriden by
Implements
|
#
|
public
|
map(callable $callback): static
Run a map over each of the items.
Run a map over each of the items.
Overriden by
Implements
|
#
|
public
|
mapToDictionary(callable $callback): static
Run a dictionary map over the items.
Run a dictionary map over the items.
The callback should return an associative array with a single key/value pair.
Implements
|
#
|
public
|
mapWithKeys(callable $callback): static
Run an associative map over each of the items.
Run an associative map over each of the items.
The callback should return an associative array with a single key/value pair.
Overriden by
Implements
|
#
|
public
|
merge(mixed $items): static
Merge the collection with the given items.
Merge the collection with the given items.
Overriden by
Implements
|
#
|
public
|
mergeRecursive(mixed $items): static
Recursively merge the collection with the given items.
Recursively merge the collection with the given items.
Implements
|
#
|
public
|
combine(mixed $values): static
Create a collection by using this collection for keys and another for its values.
Create a collection by using this collection for keys and another for its values.
Implements
|
#
|
public
|
union(mixed $items): static
Union the collection with the given items.
Union the collection with the given items.
Implements
|
#
|
public
|
nth(int $step, int $offset = 0): static
Create a new collection consisting of every n-th element.
Create a new collection consisting of every n-th element.
Implements
|
#
|
public
|
only(mixed $keys): static
Get the items with the specified keys.
Get the items with the specified keys.
Overriden by
Implements
|
#
|
public
|
pop(int $count = 1): mixed
Get and remove the last N items from the collection.
Get and remove the last N items from the collection.
|
#
|
public
|
prepend(mixed $value, mixed $key = null): $this
Push an item onto the beginning of the collection.
Push an item onto the beginning of the collection.
|
#
|
public
|
push(mixed ...$values): $this
Push one or more items onto the end of the collection.
Push one or more items onto the end of the collection.
|
#
|
public
|
concat(iterable $source): static
Push all of the given items onto the collection.
Push all of the given items onto the collection.
Implements
|
#
|
public
|
pull(mixed $key, mixed $default = null): mixed
Get and remove an item from the collection.
Get and remove an item from the collection.
|
#
|
public
|
put(mixed $key, mixed $value): $this
Put an item in the collection by key.
Put an item in the collection by key.
|
#
|
public
|
random(int|null $number = null): static|mixed
Get one or a specified number of items randomly from the collection.
Get one or a specified number of items randomly from the collection.
Throws
Implements
|
#
|
public
|
replace(mixed $items): static
Replace the collection items with the given items.
Replace the collection items with the given items.
Implements
|
#
|
public
|
replaceRecursive(mixed $items): static
Recursively replace the collection items with the given items.
Recursively replace the collection items with the given items.
Implements
|
#
|
public
|
reverse(): static
Reverse items order.
|
#
|
public
|
search(mixed $value, bool $strict = false): mixed
Search the collection for a given value and return the corresponding key if successful.
Search the collection for a given value and return the corresponding key if successful.
Implements
|
#
|
public
|
shift(int $count = 1): mixed
Get and remove the first N items from the collection.
Get and remove the first N items from the collection.
|
#
|
public
|
shuffle(int|null $seed = null): static
Shuffle the items in the collection.
Shuffle the items in the collection.
Implements
|
#
|
public
|
sliding(int $size = 2, int $step = 1): static
Create chunks representing a "sliding window" view of the items in the collection.
Create chunks representing a "sliding window" view of the items in the collection.
|
#
|
public
|
skip(int $count): static
Skip the first {$count} items.
Skip the first {$count} items.
Implements
|
#
|
public
|
skipUntil(mixed $value): static
Skip items in the collection until the given condition is met.
Skip items in the collection until the given condition is met.
Implements
|
#
|
public
|
skipWhile(mixed $value): static
Skip items in the collection while the given condition is met.
Skip items in the collection while the given condition is met.
Implements
|
#
|
public
|
slice(int $offset, int|null $length = null): static
Slice the underlying collection array.
Slice the underlying collection array.
Implements
|
#
|
public
|
split(int $numberOfGroups): static
Split a collection into a certain number of groups.
Split a collection into a certain number of groups.
Implements
|
#
|
public
|
splitIn(int $numberOfGroups): static
Split a collection into a certain number of groups, and fill the first groups completely.
Split a collection into a certain number of groups, and fill the first groups completely.
|
#
|
public
|
sole(mixed $key = null, mixed $operator = null, mixed $value = null): mixed
Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
Throws
|
#
|
public
|
firstOrFail(mixed $key = null, mixed $operator = null, mixed $value = null): mixed
Get the first item in the collection but throw an exception if no matching items exist.
Get the first item in the collection but throw an exception if no matching items exist.
Throws
|
#
|
public
|
chunk(int $size): static
Chunk the collection into chunks of the given size.
Chunk the collection into chunks of the given size.
Implements
|
#
|
public
|
chunkWhile(callable $callback): static
Chunk the collection into chunks with a callback.
Chunk the collection into chunks with a callback.
Implements
|
#
|
public
|
sort(callable|int|null $callback = null): static
Sort through each item with a callback.
Sort through each item with a callback.
Implements
|
#
|
public
|
sortDesc(int $options = SORT_REGULAR): static
Sort items in descending order.
Sort items in descending order.
Implements
|
#
|
public
|
sortBy(callable|array|string $callback, int $options = SORT_REGULAR, bool $descending = false): static
Sort the collection using the given callback.
Sort the collection using the given callback.
Implements
|
#
|
public
|
sortByDesc(callable|string $callback, int $options = SORT_REGULAR): static
Sort the collection in descending order using the given callback.
Sort the collection in descending order using the given callback.
Implements
|
#
|
public
|
sortKeys(int $options = SORT_REGULAR, bool $descending = false): static
Sort the collection keys.
Sort the collection keys.
Implements
|
#
|
public
|
sortKeysDesc(int $options = SORT_REGULAR): static
Sort the collection keys in descending order.
Sort the collection keys in descending order.
Implements
|
#
|
public
|
sortKeysUsing(callable $callback): static
Sort the collection keys using a callback.
Sort the collection keys using a callback.
|
#
|
public
|
splice(int $offset, int|null $length = null, mixed $replacement = []): static
Splice a portion of the underlying collection array.
Splice a portion of the underlying collection array.
|
#
|
public
|
take(int $limit): static
Take the first or last {$limit} items.
Take the first or last {$limit} items.
Implements
|
#
|
public
|
takeUntil(mixed $value): static
Take items in the collection until the given condition is met.
Take items in the collection until the given condition is met.
Implements
|
#
|
public
|
takeWhile(mixed $value): static
Take items in the collection while the given condition is met.
Take items in the collection while the given condition is met.
Implements
|
#
|
public
|
transform(callable $callback): $this
Transform each item in the collection using a callback.
Transform each item in the collection using a callback.
|
#
|
public
|
undot(): static
Convert a flatten "dot" notation array into an expanded array.
Convert a flatten "dot" notation array into an expanded array.
|
#
|
public
|
unique(string|callable|null $key = null, bool $strict = false): static
Return only unique items from the collection array.
Return only unique items from the collection array.
Overriden by
Implements
|
#
|
public
|
values(): static
Reset the keys on the underlying array.
Reset the keys on the underlying array.
Implements
|
#
|
public
|
zip(mixed ...$items): static
Zip the collection together with one or more arrays.
Zip the collection together with one or more arrays.
e.g. new Collection([1, 2, 3])->zip([4, 5, 6]);
=> [[1, 4], [2, 5], [3, 6]]
Overriden by
Implements
|
#
|
public
|
pad(int $size, mixed $value): static
Pad collection to the specified length with a value.
Pad collection to the specified length with a value.
Overriden by
Implements
|
#
|
public
|
getIterator(): ArrayIterator
Get an iterator for the items.
Get an iterator for the items.
Implements
|
#
|
public
|
count(): int
Count the number of items in the collection.
Count the number of items in the collection.
Implements
|
#
|
public
|
countBy(callable|string $countBy = null): static
Count the number of items in the collection by a field or using a callback.
Count the number of items in the collection by a field or using a callback.
Implements
|
#
|
public
|
add(mixed $item): $this
Add an item to the collection.
Add an item to the collection.
|
#
|
public
|
toBase(): Collection
Get a base Support collection instance from this collection.
Get a base Support collection instance from this collection.
|
#
|
public
|
offsetExists(mixed $key): bool
Determine if an item exists at an offset.
Determine if an item exists at an offset.
Implements
|
#
|
public
|
offsetGet(mixed $key): mixed
Get an item at a given offset.
Get an item at a given offset.
Implements
|
#
|
public
|
offsetSet(mixed $key, mixed $value): void
Set the item at a given offset.
Set the item at a given offset.
Implements
|
#
|
public
|
offsetUnset(mixed $key): void
Unset the item at a given offset.
Unset the item at a given offset.
Implements
|
#
|