Last active
November 23, 2018 08:21
-
-
Save renalpha/344699dcd40225e62e0368c67f6d2e2e to your computer and use it in GitHub Desktop.
Easy mailables by using notifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@component('mail::message') | |
{{-- Greeting --}} | |
@if (! empty($greeting)) | |
# {{ $greeting }} | |
@else | |
@if ($level == 'error') | |
# Whoops! | |
@else | |
# Hello! | |
@endif | |
@endif | |
{{-- Intro Lines --}} | |
@foreach ($introLines as $line) | |
{{ $line }} | |
@endforeach | |
{{-- Action Button --}} | |
@isset($actionText) | |
<?php | |
switch ($level) { | |
case 'success': | |
$color = 'green'; | |
break; | |
case 'error': | |
$color = 'red'; | |
break; | |
default: | |
$color = 'blue'; | |
} | |
?> | |
@component('mail::button', ['url' => $actionUrl, 'color' => $color]) | |
{{ $actionText }} | |
@endcomponent | |
@endisset | |
{{-- Outro Lines --}} | |
@foreach ($outroLines as $line) | |
{{ $line }} | |
@endforeach | |
{{-- Salutation --}} | |
@if (! empty($salutation)) | |
{{ $salutation }} | |
@else | |
Regards,<br>{{ config('app.name') }} | |
@endif | |
{{-- Subcopy --}} | |
@isset($actionText) | |
@component('mail::subcopy') | |
If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below | |
into your web browser: [{{ $actionUrl }}]({{ $actionUrl }}) | |
@endcomponent | |
@endisset | |
@endcomponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Mail; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Mail\Mailable; | |
use Illuminate\Queue\SerializesModels; | |
/** | |
* Class Mailable | |
* @package Olaf\Mail | |
*/ | |
class Mailable extends Mailable | |
{ | |
use Queueable, SerializesModels; | |
/** | |
* Mailable constructor. | |
* | |
*/ | |
public function __construct() | |
{ | |
// | |
} | |
/** | |
* Build the message. | |
* | |
* @return $this | |
*/ | |
public function build() | |
{ | |
return $this | |
->markdown('vendor.notifications.email', | |
['programme', $this->programme, | |
'level' => 'default', | |
'greeting' => 'Hello,', | |
'introLines' => [ | |
'Intro line 1', | |
'Intro line 2', | |
], | |
'actionText' => 'Manage programme', | |
'actionUrl' => url('/admin/'), | |
'outroLines' => [ | |
'Outro Line 1', | |
'Outro Line 2', | |
]]) | |
->subject('Your subject'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should publish the notifications email template or copy from above.