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(['product_id' => 1, 'name' => 'Desk']);
2
3$collection->put('price', 100);
4
5$collection->all();
6
7// ['product_id' => 1, 'name' => 'Desk', 'price' => 100]