Articles

Laravel 5 Collections: Adding an Element to the Beginning of a Collection With prepend

Laravel 5 The prepend method will add a a given $value to the beginning of the collection. You can also supply an optional $key that will be used as the key for the new $value when adding an item to the beginning of an...

Laravel 5 Collections: Adding an Element to the End of a Collection With push

Laravel 5 The push method is the logical opposite of the prepend method and will push an item onto the end of the collection. The push method returns a reference to the original collection instance. The push method...

Laravel 5 Collections: Adding New Elements to a Collection With put

Laravel 5 The put method is used to add a new item to the collection with a given $key and $value. The put method modifies the original Collection instance and returns a reference to it. Signature public function put( ...

Laravel 5 Collections: Adding Values to a Collection With union

Laravel 5 The union method will add the $items value to a copy of the existing collection. If there are key collisions between the collection instance and the provided $items, the elements from the collection instance...

Laravel 5 Collections: Breaking a Collection Into a Specified Number of Groups With split

Laravel 5 The split method is similar to the chunk method in that it used to break a collection into a smaller number of collections. However, when using the split method, you specify the number of groups you would like...