我不知道为什么会收到错误:删除{{ $client->name }}
时出现“试图获取非对象的属性'name'”的错误。工作正常
查看消息:
<p>
Hello {{ $client->name }},<br />
There's a new promotion.
</p>
控制器:
public function hello_client( Client $client){
Mail::to($admin, $clients)->send(new ClientNewMessage($client));
}
消息:
class ClientNewMessage extends Mailable
{
use Queueable, SerializesModels;
public $client;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($client)
{
$this->client = $client;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('New promotion')
->view('emails.clientnewmessage');
}
谢谢您的帮助!
答案 0 :(得分:1)
您调用函数并写错了$client
public function hello_client( Client $client){
Mail::to($admin, $client)->send(new ClientNewMessage($client));
}
并且为此更改了方法
public function build()
{
return $this->subject('New promotion')->view('emails.clientnewmessage')
->with('client',$this->client);
}