이 변경 시도하십시오, 누군가가 도움을 줄 수있는 경우
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()]);
}
}
은, 정말 감사합니다 :
$message->from(Auth::user()->email);
여기 내 코드입니다 사용자 테이블에 email
열이 있다고 가정합니다.
POST/GET을 통해'user_id'와'forum_id'를 전달합니까? – manix
둘 다 POST를 통해 있습니다 –