Lay*_*hic 6 php email notify laravel
我想向Notify发送邮件,它可以工作,但是当我尝试放置变量时,它返回未定义的变量。我不知道如何将变量传递给Notify,我尝试这样做,->withResult($result)但是没有成功。这是控制器:
$result = Review::where('user_hash', '=', $data['lname_c'])->where('email', $data['email_c'])->orderBy('created_at', 'desc')->first();
$result->notify(new SendReview());
Run Code Online (Sandbox Code Playgroud)
和我的SendReview.php通知:
public function toMail($notifiable)
{
return $result['invitation_id']; // test to check if variable is passed
return (new MailMessage)
->line('Test.')
->action('Nani', url($url))
->line('Thank you');
}
Run Code Online (Sandbox Code Playgroud)
我的评论表中有user_hash和Invitation_id,我想将它们传递给notify。当我这样做的return $result['invitation_id'];时候。希望我可以理解,我检查了重复的问题,但找不到一个。
这就是他们在文档中的操作方式。
$arr = [ 'foo' => "bar" ];
$result->notify(new SendReview($arr));
Run Code Online (Sandbox Code Playgroud)
在你的 SendReview.php
...
protected $arr;
public function __construct(array $arr) {
$this->arr = $arr;
}
public function toMail($notifiable) {
// Access your array in here
dd($this->arr);
}
Run Code Online (Sandbox Code Playgroud)