Thursday, March 16, 2017

[SOLVED]Laravel 5.4 - How to customize notification email layout?

I am trying to customize the HTML email layout that is used when sending notifications via email.
I have published both the mail and notification views.
php artisan vendor:publish --tag=laravel-mail
php artisan vendor:publish --tag=laravel-notifications
If I modify the /resources/views/vendor/notifications/email.blade.php file, I can only change the BODY content of the emails that get sent. I am looking to modify the footer, header, and every other part of the email layout as well.
I tried also modifying the views inside /resources/vendor/mail/html/, but whenever the notification gets sent, it is not even using these views and instead uses the default laravel framework ones.
I am aware I can set a view on the MailMessage returned by my Notification class, but I want to keep the standard line(), greeting(), etc. functions.
Does anyone know how I can get my notifications to send email using the views in /resources/vendor/mail/html ?
enter image description here
The following is my /resources/views/vendor/notifications/email.blade.php file, but it does not have anywhere to customize the header/footer/ overall layout.
@component('mail::message')

@if (! empty($greeting))
# 
@else
@if ($level == 'error')
# Whoops!
@else
# Hello!
@endif
@endif


@foreach ($introLines as $line)


@endforeach


@if (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])

@endcomponent
@endif


@foreach ($outroLines as $line)


@endforeach

<!-- Salutation -->
@if (! empty($salutation))

@else
Regards,<br>
@endif

<!-- Subcopy -->
@if (isset($actionText))
@component('mail::subcopy')
If you’re having trouble clicking the "" button, copy and paste the URL below
into your web browser: []()
@endcomponent
@endif
@endcomponent



via Brian Glaz

Advertisement