Articles

Laravel 5 Collections: Excluding Collection Elements With except

Laravel 5 The except method will return all the key/value pairs in the collection where the keys in the collection are not in the supplied $keys array. Internally, this method makes a call to the...

Laravel 5 Collections: Execute a Callback on the Collection Instance While Returning the Original Collection Instance With tap

Laravel 5 The tap method will allow you supply a callback that will receive a copy of the current collection instance. The user supplied function will not modify the original collection, but will return a...

Laravel 5 Collections: Executing a Function on a Collection and Returning the Function Results With pipe

Laravel 5 The pipe method is similar to the tap method in that it executes the provided $callback function on a copy of the collection; however, unlike the tap method, the pipe method returns the result of the callback...

Laravel 5 Collections: Executing a Function On All Collection Elements With each

Laravel 5 The each method accepts a $callback which will be called on each item in the collection. If the $callback returns false, the each method will break from its iterator and return a reference back to the original...

Laravel 5 Collections: Executing a Function on Collection Elements and Values With mapSpread

Laravel 5 The mapSpread method is used to execute a callback on a collection. If the collection contains nested collections, or Traversable objects, the mapSpread will supply the elements of the nested collections as the...