In Laravel

Laravel Collection Public API: jsonSerialize

Nov 29, 2016

The jsonSerialize method is used internally by the toArray method in PHP's JsonSerializable interface. This interface allows developers to define custom representations of a class when using the json_encode function. In the provided example, a new collection is created and the jsonSerialize method is used to obtain an array of its values. The resulting array would contain the values 'first', 'second', and 'third'.
Laravel Collection Public API: keys

Nov 29, 2016

The keys method in Laravel retrieves all the keys of the items in a collection. It returns a new Collection instance. You can use this method to get the keys of both indexed and associative arrays.
Laravel Collection Public API: last

Nov 29, 2016

The last method in Laravel's Collection class is used to retrieve the last item in a collection or the last item that matches a specified condition. It takes an optional callback function ($callback) to perform the truth test, and a default value argument ($default) to return when no matching items are found. If the collection is empty, null is returned, unless a default value is provided.
Laravel Collection Public API: lists

Nov 29, 2016

The lists method in Laravel is an alias of the pluck method. It retrieves a list of values from a collection. You can specify a property to become the value and another property to become the key in the resulting collection. There is also an example provided demonstrating the usage of the lists method to retrieve product names and versions from a collection. Another example shows how to get a new collection with the version as the value and the product name as the key.
Laravel Collection Public API: map

Nov 29, 2016

The map method in Laravel allows you to apply a given callback to each item in a collection, creating a new collection with the modified items. The provided callback should accept the item and its key as arguments. In the example, the map method is used to transform the case of each string in a collection to upper-case, resulting in a new collection with the modified values. The original collection remains unchanged.
Laravel Collection Public API: max

Nov 29, 2016

Learn how to use the max() method in Laravel to retrieve the maximum value of a given key. By default, the key is set to null, similar to PHP's max() function. Follow the provided code examples to see how to use the max() method without specifying a key or when specifying a key.
Laravel Collection Public API: merge

Nov 29, 2016

The merge method in Laravel allows you to combine the items in a collection with other items. If a string key with the same value already exists in the collection, it will be replaced. Numeric keys in the new items will be added to the end of the collection. You can pass an array or another Collection instance to the merge method, and it will return a new instance of Collection.
Laravel Collection Public API: min

Nov 29, 2016

The min method in Laravel is used to retrieve the minimum value of a given key. If no key is specified, it will return the minimum value of the collection. You can also use the min method to retrieve the minimum value of a specific key in a collection of arrays. For example, $min will contain the value 0 when the min method is called without specifying a key, and $min will contain the value 5.0 when called with the key 'version'.
Laravel Collection Public API: toArray

Nov 29, 2016

The toArray method in Laravel converts a collection or an object instance that implements the Arrayable interface into an array. It returns the underlying array that the collection instance is using. This method is useful when you need to work with the data in array format rather than a collection.
Laravel MessageBag Public API: __toString

Nov 29, 2016

Learn how to cast a MessageBag instance to a string in Laravel. The resulting value will be the JSON representation of the instance. This can be useful when you want to return error messages as JSON. Additionally, click through a series of articles to explore the public API of Laravel's ErrorMessageBag component and learn about its various methods and functionalities.
Laravel MessageBag Public API: add

Nov 29, 2016

The add method in Laravel is used to add a new message to a MessageBag instance. This method takes a key and a message as parameters and returns a reference to the current MessageBag instance. A key can be any value that makes sense in the given context, and multiple messages can be stored under the same key as long as they are unique. In the case of form validation, the key is usually the name of the form field being validated. This article is part of a series that explains the Laravel ErrorMessageBag component in detail, and you can continue reading to explore the various public APIs available for working with MessageBag instances.
Laravel MessageBag Public API: all

Nov 29, 2016

The all method in Laravel's MessageBag class retrieves all messages in a given format. By default, the format is null, using the format stored within the MessageBag instance. Developers can provide a custom format as an argument. The method returns an array with all the formatted messages. The article provides an example of creating a new MessageBag instance and retrieving all messages with a specified format using the all method. Continue reading to learn more about Laravel's ErrorMessageBag component and its public API, including methods like add, any, count, first, get, and setFormat.
Laravel MessageBag Public API: any

Nov 29, 2016

The any method in Laravel's MessageBag class checks if there are any messages in the instance and returns a boolean value. It returns true if there are messages, and false otherwise. You can use this method to quickly verify if there are any messages in a MessageBag instance. To learn more about Laravel's ErrorMessageBag component and its public API, you can continue reading the articles in this mini-series.
Laravel MessageBag Public API: count

Nov 29, 2016

The count method in Laravel's Collection class returns the total number of items in the collection. It is a simple and straightforward method that returns an integer. If you want to learn more about Laravel's ErrorMessageBag component and other related topics, you can continue reading through the articles in the provided links.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.