I have a Laravel mailable like this:
...
public function build()
{
return $this->subject('Ticket Created ['.$this->ticket->ticket_code.']')
->view('emails.support.ticketcreated')->with([
'ticket' => $this->ticket
]);
}
Then I have a template for the email in my views directory:
<div class="card">
<div class="card-header bg-dark">
Ticket Created [{{ $ticket->ticket_code }}]
</div>
<div class="card-body">
<p>Thanks for creating a ticket! We will get back to you as soon as possible</p>
<p><a href="{{ $ticket->url }}">To view your ticket click here</a></p>
</div>
</div>
I want to wrap this in the default Laravel email template (so put all the above into the $slot
section in the layout)
I've published the Laravel email templates using:
php artisan vendor:publish --tag=laravel-mail
And I can see the layout file that I want to use under:
resources/views/vendor/mail/html/layout.blade.php
The problem is I can't seem to use this layout.
I've tried the following (but all have failed):
Wrapping the email template with but then it just tries to use my app layout (not the mail layout).
Using
@extends('vendor.mail.html.layout')
and@section('slot')
Tried adding ->layout('vendor.mail.html.layout'); to the end of the view() in mailable
build()
(just gives error method not found)
How can I use this layout for my emails. Note that I don't want to create a separate duplicate layout as then I'll have two layouts to manage.