Overview
TheCollection class wraps arrays and provides a fluent, chainable API for filtering, sorting, transforming, and aggregating data. It’s inspired by Laravel Collections and is returned by QueryBuilder and Model queries.
Creating Collections
Static Constructors
make()
make()
wrap()
wrap()
times()
times()
range()
range()
Basic Operations
all()
all()
count()
count()
isEmpty()
isEmpty()
isNotEmpty()
isNotEmpty()
first()
first()
last()
last()
Filtering
filter()
filter()
where()
where()
whereIn()
whereIn()
whereNotIn()
whereNotIn()
whereNull()
whereNull()
whereNotNull()
whereNotNull()
Transformation
map()
map()
flatMap()
flatMap()
pluck()
pluck()
unique()
unique()
Sorting
sort()
sort()
sortBy()
sortBy()
sortByDesc()
sortByDesc()
reverse()
reverse()
Chunking & Slicing
chunk()
chunk()
slice()
slice()
take()
take()
skip()
skip()
forPage()
forPage()
Grouping
groupBy()
groupBy()
keyBy()
keyBy()
Aggregation
sum()
sum()
avg()
avg()
max()
max()
min()
min()
Boolean Checks
contains()
contains()
every()
every()
some()
some()
Iteration
each()
each()
tap()
tap()
pipe()
pipe()
reduce()
reduce()
Advanced Operations
collapse()
collapse()
Collapse a collection of arrays into a single flat collection.
Returns a new flattened Collection
flatten()
flatten()
diff()
diff()
intersect()
intersect()
merge()
merge()
Random & Shuffling
random()
random()
shuffle()
shuffle()
Conversion
toArray()
toArray()
toJSON()
toJSON()
values()
values()
Get collection of values (for object collections).
Returns a new Collection of values
keys()
keys()