Skip to content

Commit 50efe09

Browse files
committed
add addIf method to message bag
1 parent 076c979 commit 50efe09

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Illuminate/Support/MessageBag.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ public function add($key, $message)
6666
return $this;
6767
}
6868

69+
/**
70+
* Add a message to the message bag if the given conditional is "true".
71+
*
72+
* @param bool $boolean
73+
* @param string $key
74+
* @param string $message
75+
* @return $this
76+
*/
77+
public function addIf($boolean, $key, $message)
78+
{
79+
return $boolean ? $this->add($key, $message) : $this;
80+
}
81+
6982
/**
7083
* Determine if a key and message combination already exists.
7184
*

0 commit comments

Comments
 (0)