Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Confused as to what to do at step 4. #148

Open
mariusberget92 opened this issue Oct 29, 2022 · 2 comments
Open

[Question] Confused as to what to do at step 4. #148

mariusberget92 opened this issue Oct 29, 2022 · 2 comments

Comments

@mariusberget92
Copy link

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 [];
    }
}
@rizaljamhari
Copy link
Contributor

rizaljamhari commented Jan 4, 2023

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'],
    );
}

@mariusberget92
Copy link
Author

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'],
    );
}

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants