Skip to content

[13.x] Add lineUnless and linesUnless to notification messages#60267

Closed
LucasCavalheri wants to merge 1 commit into
laravel:13.xfrom
LucasCavalheri:feat/simple-message-unless-methods
Closed

[13.x] Add lineUnless and linesUnless to notification messages#60267
LucasCavalheri wants to merge 1 commit into
laravel:13.xfrom
LucasCavalheri:feat/simple-message-unless-methods

Conversation

@LucasCavalheri
Copy link
Copy Markdown
Contributor

Summary

This PR adds lineUnless and linesUnless methods to notification messages via SimpleMessage.

These methods provide the inverse conditional behavior of the existing lineIf and linesIf helpers:

$message->lineUnless($condition, '...');
$message->linesUnless($condition, [
    '...',
]);

This keeps the API consistent with Laravel's broader when / unless conventions and improves readability when the negative condition is the intended flow.

Motivation

SimpleMessage already provides conditional helpers through lineIf and linesIf, but currently lacks their unless counterparts.

Without these methods, developers must negate conditions manually:

$message->lineIf(! $condition, '...');

Adding dedicated unless variants improves expressiveness and keeps the notification API symmetrical and consistent with other framework patterns.

Changes

  • Added lineUnless() to SimpleMessage
  • Added linesUnless() to SimpleMessage
  • Added test coverage for both methods

Tests

Added the following tests to NotificationMailMessageTest:

  • testLineUnless
  • testLinesUnless

Verified with:

./vendor/bin/phpunit tests/Notifications/NotificationMailMessageTest.php --filter Unless

Backward Compatibility

This change is fully backward compatible and only introduces additional convenience methods without altering existing behavior.

@taylorotwell
Copy link
Copy Markdown
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants