laravel-mjml
laravel-mjml copied to clipboard
[Question] Confused as to what to do at step 4.
Hi. I am a bit confused as to what to do when I come to step 4: In the build method, use: $this->mjml('view.name');
When I generated the mail class, I cannot see any build method anywhere. When I try to add the build method, VSCode suggests a buildViewData
method instead. I added the whole generated mail class below. Sorry if I have misunderstood something.
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Asahasrabuddhe\LaravelMJML\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class EmailVerificationMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(
subject: 'Email Verification Mail',
);
}
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(
view: 'view.name',
);
}
/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}
In Laravel 9, there's no build
method anymore. It was replaced by content
method.
For Laravel 9, use this:
public function content()
{
return new Content(
view: $this->mjml('view.name')->buildMjmlView()['html'],
);
}
In Laravel 9, there's no
build
method anymore. It was replaced bycontent
method. For Laravel 9, use this:public function content() { return new Content( view: $this->mjml('view.name')->buildMjmlView()['html'], ); }
Thank you! :)