4 months ago

How to add Variable into Mailable's build() function?

Posted 4 months ago by FaiChan

My email is sending by Mailable (Laravel 5.5).

how to can add the variable into the public function build()?

I like to customize the subject name with the variable. Thanks for your help.

namespace App\Mail;

use App\Task;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class TranslationTask extends Mailable
    use Queueable, SerializesModels;

    protected $task;
     * Create a new message instance.
     * @param $task
    public function __construct(Task $task)

        $this->task = $task;

     * Build the message.
     * @return $this
    public function build()

        return $this->markdown('emails.translation')


Please sign in or create an account to participate in this conversation.