Skip to content

Instantly share code, notes, and snippets.

@renalpha
Last active November 23, 2018 08:21
Show Gist options
  • Save renalpha/344699dcd40225e62e0368c67f6d2e2e to your computer and use it in GitHub Desktop.
Save renalpha/344699dcd40225e62e0368c67f6d2e2e to your computer and use it in GitHub Desktop.
Easy mailables by using notifications
@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
<?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');
}
}
@renalpha
Copy link
Author

You should publish the notifications email template or copy from above.

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