Search

Laravel MessageBag Public API: any

November 29, 2016 —John Koster

The any method returns a boolean value indicating if the MessageBag instance actually has any messages. The method returns true if the instance has messages, otherwise it returns false. The following code examples demonstrate the usage of this fairly simple method:

1<?php
2 
3use Illuminate\Support\MessageBag;
4 
5// Create a new MessageBag instance.
6$messageBag = new MessageBag;
7 
8// false
9$hasAny = $messageBag->any();
10 
11$messageBag->addMessage('first', 'The first message');
12 
13// true
14$hasAny = $messageBag->any();

#Continue Reading

This article is the start of a mini-series about Laravel's ErrorMessageBag component. Click through the rest of the articles to continue reading:

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.