i want to send emails to client multiple email id i am collective email data like this
$emails = EmailClient::whereHas('client', function ($query) use($client){
$query->where('id', $client->id);
})->get();
now i want to add collected email in array
$mail = Mail::to([$emails->email])->send(new SendInvoice($client));
Getting Error help me for sort out
答案 0 :(得分:1)
对于单个电子邮件,您可以使用first
方法
$emails = EmailClient::whereHas('client', function ($query) use($client){
$query->where('id', $client->id);
})->select("email")->first();
如果您希望表格中的所有电子邮件都为数组,请使用pluck
$emails = EmailClient::whereHas('client', function ($query) use($client){
$query->where('id', $client->id);
})->pluck("email");
像这样通过
$mail = Mail::to($emails)->send(new SendInvoice($client));