Search

Showing 7 of 587 result(s)

/blog/2018/04/22/laravel-5-collections-filtering-collection-elements-using-strict-comparison-operators-with-wherestrict

The whereStrict method is similar to the where method, but it will always use strict comparisons when determining the results to return.The $sampleCollection collection instance will be used in the following examples: If you noticed, the first...

/blog/2018/04/22/laravel-5-collections-filtering-collection-elements-with-filter

The filter method applies a filter to the collection. An optional $callback can be supplied to the filter method. If no $callback is supplied to the filter method, any value in the collection that evaluates to false will be removed from the final...

/blog/2018/04/22/laravel-5-collections-filtering-collection-elements-with-where

The where method allows developers to filter a collection given a key value pair. It filters the collection's items by checking that the given $key has some value equal to the provided $value . An argument can be supplied for the $operator...

/blog/2018/04/22/laravel-5-collections-getting-the-number-of-elements-in-a-collection-with-count

The count method will return the number of elements contained within the collection's inner array; it is synonymous with PHP's count function.public function count();The count method is a straightforward method and simply returns the total number...

/blog/2018/04/22/laravel-5-collections-grouping-collection-elements-with-groupby

The groupBy method is used to group a collection based on a given value, represented by the $groupBy parameter. An argument passed to $groupBy can be a simple string, representing the value that the collection should be grouped by, or a callback...

/blog/2018/04/22/laravel-5-collections-grouping-collection-elements-with-groupby#content-preserving-keys-with-groupby

By default, the groupBy method will not preserve the keys in the underlying collection when grouping items. The following code sample shows how the groupBy method groups by default, and the output: The $grouped variable would now have a value...

/blog/2018/04/22/laravel-5-collections-paginating-collections-with-forpage#content-using-chunk-to-achieve-similar-results

The chunk method can be used to achieve similar results. The following code sample will use the same collection from the previous example, and chunk it into smaller collections each containing two items. The $pages variable is also an instance of...