Search

Showing 7 of 1,216 result(s)

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

intersect($items) The intersect removes any values that are not in the provided $items array. The intersect method returns a new instance of Collection . The intersect method preserves any keys from the original collection. The following code...

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

isEmpty The isEmpty can be used to determine if the collection has items or not. If the collection has no items, true will be returned, otherwise false will be returned.

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

jsonSerialize The jsonSeralize method internally returns the value of the toArray method. This method exists to implement PHP's JsonSerializable interface, which allows developers to customize how a class is represented when using the json_encode...

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

keys The keys method is used to retrieve the keys of all items in the collection. The keys method returns a new Collection instance. The following code example demonstrates the usage of the keys method: After the above code executes, the $keys...

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

last(callable $callback = null, $default = null) The last method is the logical opposite of the first method, and is used to get the last item in a collection, or to get the last item in a collection that matches a certain criteria. A $callback...

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

lists($value, $key = null) The lists method is an alias of the pluck method. The lists method is used to retrieve the a list of values from the collection. It defines two parameters: $value and $key . The $value indicates which property should...

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

map(callable $callback) The map method applies a given $callback to each item in the collection. The $callback can modify the item which will be added to a new collection. The map method does not modify the original collection, but returns a new...