Skip to content

Commit 3a0ad1a

Browse files
authored
Add conditional line to MailMessage (#43387)
1 parent dc0c777 commit 3a0ad1a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Illuminate/Notifications/Messages/SimpleMessage.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,22 @@ public function line($line)
157157
return $this->with($line);
158158
}
159159

160+
/**
161+
* Add a line of text to the notification if the given condition is true.
162+
*
163+
* @param bool $boolean
164+
* @param mixed $line
165+
* @return $this
166+
*/
167+
public function lineIf($boolean, $line)
168+
{
169+
if ($boolean) {
170+
return $this->line($line);
171+
}
172+
173+
return $this;
174+
}
175+
160176
/**
161177
* Add lines of text to the notification.
162178
*
@@ -172,6 +188,22 @@ public function lines($lines)
172188
return $this;
173189
}
174190

191+
/**
192+
* Add lines of text to the notification if the given condition is true.
193+
*
194+
* @param bool $boolean
195+
* @param iterable $lines
196+
* @return $this
197+
*/
198+
public function linesIf($boolean, $lines)
199+
{
200+
if ($boolean) {
201+
return $this->lines($lines);
202+
}
203+
204+
return $this;
205+
}
206+
175207
/**
176208
* Add a line of text to the notification.
177209
*

0 commit comments

Comments
 (0)