Search

The blog - interstellar.

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.
Laravel MessageBag Public API: first

Nov 29, 2016

The first method in Laravel's MessageBag class retrieves the first message stored within the instance. You can specify a specific key to retrieve the first message associated with that key. If no messages are found, an empty string is returned. Additionally, you can customize the format of the returned message. This method is part of a larger series of articles on Laravel's MessageBag component.
Laravel MessageBag Public API: get

Nov 29, 2016

The get method in Laravel's MessageBag class retrieves all messages associated with a given key and format. By default, the format is null and uses the format stored within the MessageBag instance. Developers can customize the format by specifying their own. The method returns an array of all the formatted messages. You can learn more about Laravel's ErrorMessageBag component by reading the rest of the articles in the mini-series.
Laravel MessageBag Public API: getFormat

Nov 29, 2016

The getFormat method is used to retrieve the current format being used by the MessageBag instance. It returns the format as a string. This is the opposite of the setFormat method, which is used to change the format. You can use these methods to customize the way messages are displayed in Laravel's MessageBag component. To learn more about Laravel's MessageBag component and its public API, check out the following articles in this mini-series: - An Introduction to Laravel Message Bags - Laravel MessageBag Public API: add - Laravel MessageBag Public API: all - Laravel MessageBag Public API: any - Laravel MessageBag Public API: count - Laravel MessageBag Public API: first - Laravel MessageBag Public API: get - Laravel MessageBag Public API: getMessageBag - Laravel MessageBag Public API: getMessages - Laravel MessageBag Public API: has - Laravel MessageBag Public API: isEmpty - Laravel MessageBag Public API: jsonSerialize - Laravel MessageBag Public API: keys - Laravel MessageBag Public API: merge - Laravel MessageBag Public API: setFormat - Laravel MessageBag Public API: toArray - Laravel MessageBag Public API: toJson - Laravel MessageBag Public API: __toString
Laravel MessageBag Public API: getMessageBag

Nov 29, 2016

The getMessageBag method in Laravel returns a reference to the MessageBag instance, which is used to manage error messages. This method is part of Laravel's Illuminate\Contracts\Support\MessageProvider interface. To learn more about Laravel's ErrorMessageBag component and its public API, check out the articles in the mini-series linked at the end of this post.

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.