Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Add greeting option to SimpleMessage notification #15108

Merged
merged 7 commits into from
Aug 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Illuminate/Notifications/Messages/SimpleMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class SimpleMessage
*/
public $subject;

/**
* Greeting at the beginning of the notification.
* If null, a greeting depending on the level will be displayed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell I don't know what you mean, I added a new line, styleci is failing now

*
* @var string|null
*/
public $greeting = null;

/**
* The "intro" lines of the notification.
*
Expand Down Expand Up @@ -98,6 +106,19 @@ public function subject($subject)
return $this;
}

/**
* Set the greeting of the notification.
*
* @param string $greeting
* @return $this
*/
public function greeting($greeting)
{
$this->greeting = $greeting;

return $this;
}

/**
* Add a line of text to the notification.
*
Expand Down Expand Up @@ -168,6 +189,7 @@ public function toArray()
return [
'level' => $this->level,
'subject' => $this->subject,
'greeting' => $this->greeting,
'introLines' => $this->introLines,
'outroLines' => $this->outroLines,
'actionText' => $this->actionText,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{{ $level == 'error' ? 'Whoops!' : 'Hello!' }}
<?php
if ($greeting !== null) {
echo e($greeting);
} else {
echo $level == 'error' ? 'Whoops!' : 'Hello!';
}

?>

<?php

Expand Down
10 changes: 7 additions & 3 deletions src/Illuminate/Notifications/resources/views/email.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@
<td style="{{ $fontFamily }} {{ $style['email-body_cell'] }}">
<!-- Greeting -->
<h1 style="{{ $style['header-1'] }}">
@if ($level == 'error')
Whoops!
@if ($greeting !== null)
{{ $greeting }}
@else
Hello!
@if ($level == 'error')
Whoops!
@else
Hello!
@endif
@endif
</h1>

Expand Down