您好我如何将每个sender_id转换为用户电子邮件。
这是我的代码,无法让您了解我正在做什么。
$mails = Email::where('recipient_id',Auth::user()->id)->orderBy('created_at', 'ASC')->get(); // GET ALL THE MAILS THAT IS SENT TO THE USER....
$senders = $mails->get()->sender_id; //GETS ALL THE MAILS SENDER_ID
foreach ($mails as $mails) {
$mails->first()->sender_id
$sender_email = User::where('id', $mails)->first()->email; // CONVER ALL THE SENDER ID INTO USER EMAIL
}
我想要发生的是
邮件收件箱
@foreach($mails as $mail)
<tr>
<td class="mailbox-name"><a href="#">$EMAIL ADDRESS</a></td>
<td class="mailbox-subject"> <b>$mail->subject</b> </td>
</tr>
@endforeach
我做错了,如何正确行事请告诉我,做这项工作真是太蠢了我需要帮助!
答案 0 :(得分:1)
在foreach循环中,你放了$mails as $mails
会给你带来麻烦。更改变量名称。