1$collection = collect([1, 2, 3, 4]);
2
3$filtered = $collection->filter(function ($value, $key) {
4 return $value > 2;
5});
6
7$filtered->all();
8
9// [3, 4]
1$collection = collect([1, 2, 3, 4, 5, 6, 7]);
2
3$chunks = $collection->chunk(4);
4
5$chunks->toArray();
6
7// [[1, 2, 3, 4], [5, 6, 7]]