public function acceptpersonalvisitupdate(Request $request)
{ $employeeinfo=$request->input('employeeinfo');
$id=$request->input('id');
$visitoremail=$request->input('visitoremail');
$visitorname=$request->input('visitorname');
$visitorphonenumber=$request->input('visitorphonenumber');
$visitortype=$request->input('visitortype');
$empname=$request->input('empname');
$empdept=$request->input('empdept');
$date=$request->input('date');
$from=$request->input('from');
$noofhours=$request->input('noofhours');
Mail::send('mails.acceptedpersonalvisit',
['visitorname'=>$visitorname,'visitorphonenumber'=>$visitorphonenumber,
'visitoremail'=>$visitoremail,'id'=>$id,'visitortype'=>$visitortype,
'empname'=>$empname,'empdept'=>$empdept,'date'=>$date,'from'=>$from,
'noofhours'=>$noofhours,'employeeinfo'=>$employeeinfo],function($message)
{
$message->to($visitoremail,$visitorname))->subject('Personal Visit Request Accepted');
});
DB::update('update bookingtable set employeeinfo=?,staus="Approved" where id=?',[$employeeinfo,$id]);
return Redirect::to('acceptedpersonalvisits')->with('success','Successfully Accepted Personal Book Request!!!');
}
在上面的代码我有一个acceptpersonalvisitupdate post函数。它的变量是那些定义的变量列表。从那些变量我想访问$ visitoremail和$ visitorname in mail function.when我通常代表变量它显示错误为undefined变量$ visitoremail.how来访问邮件功能中的变量。非常欢迎任何帮助和建议。谢谢。
答案 0 :(得分:3)
添加use()
:
function ($message) use($visitoremail, $visitorname) {