Articles

Laravel 5 Collections: Retrieving the Distinct Values of a Collection Using Strict Comparison Operators With uniqueStrict

Laravel 5 The uniqueStrict method can be used to all of the unique items in the collection; it behaves similarly to the unique collection method in that it accepts an optional $key...

Laravel 5 Collections: Retrieving the Distinct Values of a Collection With unique

Laravel 5 The unique method can be used to get all the unique items in the collection. It accepts an optional $key argument which can be used to further restrict which items are...

Laravel 5 Collections: Retrieving the Maximum Value of a Collection With max

Laravel 5 The max method can be used to retrieve the maximum value of the given $key. By default, the $key is null and will function in a similar way to PHP's max...

Laravel 5 Collections: Sort a Collection in Descending Order With sortByDesc

Laravel 5 The sortByDesc method operates exactly the same as the sortBy method. The only differences is that the sortByDesc method does not define a $descending parameter. The...

Laravel 5 Collections: Sorting a Collection Based on a Key Value With sortBy

Laravel 5 The sortBy method is useful and versatile way to sort collections by some key, or by some value returned by a $callback. The $callback can either be a function that defines...