if ($user->save()) {
$data = DB::table('posts')->get();
$data = array(
'description' => $request->description,
'Location'=> $request->Location,
'lat' => $request->lat,
'lng' => $request->lng,
);
Mail::send('contact',$data,function($message) use($data) {
//Mail has been sent but both the From and To email address are same
// i.e. abc@gmail.com not Logged in user's email
$message->from(Auth::user()->email);
//to email address which i have hard coded
$message->to('abc@gmail.com');
$message->subject($data['Location']);
});
return redirect('/index');
}
}
答案 0 :(得分:1)
试试这个
if ($user->save()) {
$data = DB::table('posts')->get();
$data = array(
'description' => $request->description,
'Location'=> $request->Location,
'lat' => $request->lat,
'lng' => $request->lng,
);
if (Auth::check()
{
$data['email'] = User::whereId(Auth::user()->id)->value('email');
}
if(empty($data['email'])) return false;
Mail::send('contact',$data,function($message) use($data) {
//Mail has been sent but both the From and To email address are same
// i.e. abc@gmail.com not Logged in user's email
$message->from($data['email']);
//to email address which i have hard coded
$message->to($data['email']);
$message->subject($data['Location']);
});
return redirect('/index');
}
}