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// true14$hasAny = $messageBag->any();
This article is the start of a mini-series about Laravel's ErrorMessageBag
component. Click through the rest of the articles to continue reading:
∎
John Koster
Learning text parsing, manipulation, encoding and more through the Laravel string helpers.
Published on April 22, 2018
Published on November 30, 2017
Published on April 14, 2018