Search

Showing 7 of 1,697 result(s)

/blog/2018/04/22/laravel-5-collections-determining-if-a-collection-contains-an-element-with-contains

The contains method is used to determine if a given $key exists within the collection. Additionally, an optional $value can be specified that will be used to check if a given key/value pair exists within the collection. The contains method is...

/blog/2018/04/22/laravel-5-collections-determining-if-a-collection-has-an-element-with-has

The has method is used to determine if a item exists in the collection based on a given $key . The has method returns true if the item exists and false if it does not.The following example demonstrates the usage of the has method:

/blog/2018/04/22/laravel-5-collections-dumping-the-collection-contents-and-continuing-script-execution-for-debugging-with-dump

The dump method is similar to the dd method in that it is used to dump the contents of the collection to the output for debugging purposes, however, unlike the dd method, the dump method will not stop execution of the script. Because of the...

/blog/2018/04/22/laravel-5-collections-excluding-collection-elements-with-except

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 "Illuminate\Support\Arr:except($array, $keys)" helper...

/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-merging-multiple-collection-values-with-merge

The merge methods merges the given $items with the items in the collection. The merge method will replace any item in the original collection's items if a string key with the same value exists in the supplied $items . If the $items keys are...

/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...