1$collection = collect(['name' => 'taylor', 'languages' => ['php', 'javascript']]);
2
3$flattened = $collection->flatten();
4
5$flattened->all();
6
7// ['taylor', 'php', 'javascript'];
1$collection = collect([1,2,3,4]);
2
3$collection->each(function($item){
4 return $item*$item;
5});
6
7// [1,4,9,16]