The Blog

Laravel

Laravel

Laravel Collection Public API: max

John Koster
John Koster
November 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

Laravel Collection Public API: merge

John Koster
John Koster
November 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

Laravel Collection Public API: min

John Koster
John Koster
November 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

Laravel Collection Public API: toArray

John Koster
John Koster
November 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

Laravel MessageBag Public API: __toString

John Koster
John Koster
November 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

Laravel MessageBag Public API: add

John Koster
John Koster
November 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

Laravel MessageBag Public API: all

John Koster
John Koster
November 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

Laravel MessageBag Public API: any

John Koster
John Koster
November 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

Laravel MessageBag Public API: count

John Koster
John Koster
November 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

Laravel MessageBag Public API: first

John Koster
John Koster
November 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.

Latest posts

Where Things get Good: Moving on to Forte Development Phase 1

Wrapping up Forte Phase 0 with the lexer and parser now in private alpha, and kicking off Phase 1 wi...

Read more
Forte Update: Backtracking, Metadata, HTML Validation, and More

A Forte development update: the parser now supports backtracking, improvements to node metadata, ide...

Read more
Parsing HTML and Blade Attributes in Forte

Wrapping up attribute parsing in Forte's HTML parser, from simple HTML attributes to complex, edge-c...

Read more
Switch Statements and Parser Extensions in Forte

Exploring how Forte's parser extensions can be used to handle complex Blade directives like nested s...

Read more
Parsing Blade Comments in Forte

Digging into parsing Blade and HTML comments while building Forte's HTML parser for Laravel Blade.

Read more
Thoughts on HTML Elements and Blade Components in Forte

This week I’m tackling Forte's HTML parser - consolidating Blade, Flux, and Livewire components into...

Read more