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$itemCollection = collect($contacts);
2$filtered = $itemCollection->filter(function($item) use ($search) {
3 return stripos($item['username'],$search) !== false;
4});
5