Search

Showing 7 of 1,216 result(s)

/blog/2016/11/29/laravel-collection-public-api-flip

flip The flip method will return a new Collection instance where are the all the collection item's keys have been exchanged with their corresponding values. The following code example demonstrates the effects of the flip method: The...

/blog/2016/11/29/laravel-collection-public-api-forget

forget($key) The forget method removes an item from the collection based on given $key . The forget method returns a reference to the original collection, meaning it modifies the collection instance it was called on. The following code example...

/blog/2016/11/29/laravel-collection-public-api-forpage

forPage($page, $perPage) The forPage method is used to implement pagination over collections. The forPage defines two parameters: $page , which is used to tell the collection which "page" should be returned and $perPage , which is used to control...

/blog/2016/11/29/laravel-collection-public-api-get

get($key, $default = null) The get method can be used to retrieve an item from the collection based of its $key . An optional $default argument can be passed that will be returned if the given $key does not exists in the collection. The $default...

/blog/2016/11/29/laravel-collection-public-api-groupby

groupBy($groupBy, $preserveKeys = false) 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...

/blog/2016/11/29/laravel-collection-public-api-has

has($key) 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/2016/11/29/laravel-collection-public-api-implode

implode($value, $glue = null) The implode method will combine the items of the collection together. The Collection 's implode method behaves differently than PHP's implode function in that it can operate on arrays of primitive data types as well...