讓我告訴你我的問題 我有一個應用程序,用戶可以回覆評論,某些帖子有論壇,用戶可以讓他自己的意見,但是,我真正的問題是,當用戶發表新評論時,管理員可以收到一封包含答案信息的電子郵件,但在電子郵件中必須顯示以下信息:用戶電子郵件,論壇名稱和答案用戶,當答案保存在數據庫中時,保存user_id,forum_id,我需要通過電子郵件和論壇名稱在電子郵件中,但是,當我嘗試時,不要顯示信息;這裏是我的代碼:發送ID爲laravel的電子郵件
public function store(Request $request)
{
try{
$comment = new Comment;
DB::beginTransaction();
if (Auth::user()) {
$book = $request->book_id;
$comment->user_id = Auth::user()->id;
$comment->forum_id = $book;
$comment->comment = $request->comment;
$comment->multimedia_type = $request->multimedia_type;
$comment->comment_id = $request->comment_id;
}
$comment->save();
Mail::send('emails.forumEmail', array(
'user_id' => $request->get('user_id') , -> I supposse here have the information about user.
'forum_id' => $request->get('forum_id') , -> I supposse here have the information about forum.
'comment' => $request->get('comment') ,
),
function ($message) use($request)
{
// When I try pass (
$message->from($request->user_id->email);
$message->to('[email protected]')->subject('Han registrado una nueva entrada en el foro' . $request->forum_id->forum_title);
) But nothings happen, didn´t work, exactly
$message->from('[email protected]');
$message->to('[email protected]')->subject('Han registrado una nueva entrada en el foro');
});
DB::commit();
return back()->with('info', 'Tu comentario ha sido guardado exitosamente.');
}
else{
return back()->with('errors', 'Para participar en el foro debes iniciar sesión');
}
} catch (\Exception $e) {
DB::rollback();
return back()->with(['errors' => $e->getMessage()]);
}
}
如果有人能幫忙,我會非常感激,請
你通過POST/GET傳遞'user_id'和'forum_id'嗎? – manix
他們都是通過POST –