April 21, 2018 —John Koster
The has
method can be used to determine if messages exist within the MessageBag
instance for a given $key
. The has
method returns true
if messages exist for the given $key
, and returns false
if no messages exist.
The signature of the has
method is:
1public function has(2 $key3);
The following examples demonstrate the usage of the has
method:
1use Illuminate\Support\MessageBag; 2 3// Create a new MessageBag instance. 4$messageBag = new MessageBag; 5 6// false 7$hasMessage = $messageBag->has('test'); 8 9// Add the message to the message bag.10$messageBag->add('test', 'Example message');11 12// true13$hasMessage = $messageBag->has('test');
∎
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.