解决Laravel 8 undefined variable错误问题
2851
下面带大家介绍如何解决Laravel 8 使用mailable发送邮件,undefined variable错误问题,希望对大家有所帮助!
具体问题:
Laravel 8 使用mailable发送邮件,undefined variable错误?
Laravel 8 使用 mailable 的方法发送邮件,一直出现 undefined variable 的错误,但是参照网上的解决方案,使用 public 定义 variable,但是还是报同样的错误
public $jobdocumentmessage; /** * Create a new message instance. * * @return void */ public function __construct($jobdocumentmessage) { $this->jobdocumentmessage = $jobdocumentmessage; } /** * Build the message. * * @return $this */ public function build() { #dd($jobdocumentmessage); return $this->view('emails.jobDocument') ->with([ 'body' => $jobdocumentmessage->body, 'user' => $jobdocumentmessage->user, ]) ->subject($jobdocumentmessage->subject) ->replyTo($jobdocumentmessage->mail) ->attach($jobdocumentmessage->url, ['as' => $jobdocumentmessage->name ]); }
解决办法:
public $jobdocumentmessage; /** * Create a new message instance. * * @return void */ public function __construct($jobdocumentmessage) { $this->jobdocumentmessage = $jobdocumentmessage; } /** * Build the message. * * @return $this */ public function build() { $jobdocumentmessage= $this->jobdocumentmessage ; return $this->view('emails.jobDocument') ->with([ 'body' => $jobdocumentmessage->body, 'user' => $jobdocumentmessage->user, ]) ->subject($jobdocumentmessage->subject) ->replyTo($jobdocumentmessage->mail) ->attach($jobdocumentmessage->url, [ 'as' => $jobdocumentmessage->name ]); }
本文网址:https://www.zztuku.com/detail-10097.html
站长图库 - 解决Laravel 8 undefined variable错误问题
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!