I have just upgraded my 5.2
install of laravel to 5.3
and then to 5.4
following the official upgrading methods.
I am now trying to use one of the new features, to create a markdown formated email.
According to the documentation found at: https://laravel.com/docs/5.4/mail#view-data
要嵌入内嵌图像,请在
$message
上使用嵌入方法
However, this:
<img src="{{ $message->embed(public_path().'/img/official_logo.png') }}">
将产生以下错误:
未定义变量:
message
我错过什么了吗?或者升级指南中是否有未记录的内容?
稍后编辑:
I am calling the email function with:
\Mail::to($user)->send(new WelcomeCandidate($user, $request->input('password')));
候选人看起来像:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Models\User;
class WelcomeCandidate extends Mailable
{
use Queueable, SerializesModels;
public $user;
public $password;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $user, $password)
{
//
$this->user = $user;
$this->password = $password;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$this->subject('Welcome!');
return $this->markdown('emails.welcome-candidate');
}
}