Laravel 5 Message Bags: Getting the Current Message Format With getFormat

April 21, 2018 —John Koster

The getFormat is the logical opposite of the setFormat method. It simply returns the current format that is being used by the MessageBag instance.

#Signature

The signature of the getFormat method is:

1public function getFormat();

#Example Use

The following examples demonstrate the usage of the getFormat method:

1use Illuminate\Support\MessageBag;
2 
3// Create a new MessageBag instance.
4$messageBag = new MessageBag;
5 
6// :message
7$format = $messageBag->getFormat();
8 
9// Change the format.
10$messageBag->setFormat('<li>:message</li>');
11 
12// <li>:message</li>
13$format = $messageBag->getFormat();
14 
15// Reset the format.
16$messageBag->setFormat();
17 
18// :message
19$format = $messageBag->getFormat();

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.