๐Ÿงฉ Collections

Illuminate\Support\Collection โ€” 70+ methods

Numeric collection [3,1,4,1,5,9,2,6,5,3,5]
original [3,1,4,1,5,9,2,6,5,3,5]
map (ร—2) [6,2,8,2,10,18,4,12,10,6,10]
filter (>3) [4,5,9,6,5,5]
unique [3,1,4,5,9,2,6]
sort [1,1,2,3,3,4,5,5,5,6,9]
sortDesc [9,6,5,5,5,4,3,3,2,1,1]
sum 44
avg 4
min/max [1,9]
count 11
chunk(3) [[3,1,4],[1,5,9],[2,6,5],[3,5]]
take(4) [3,1,4,1]
reduce (sum) 44
first (>4) 5
contains (9) true
flatten [1,2,3,4]
zip [[1,"a"],[2,"b"],[3,"c"]]
Array-of-objects collection
pluck (name) ["Alice","Bob","Carol","Dave"]
groupBy (dept) {"Eng":["Alice","Carol"],"HR":["Bob","Dave"]}
keyBy (name) ["Alice","Bob","Carol","Dave"]
where (dept=Eng) ["Alice","Carol"]
sortBy (name) ["Alice","Bob","Carol","Dave"]