我想显示$ data表单控制器以供查看,但它显示此error message。您知道为什么以及如何解决吗?谢谢。
这是我的代码:
UserController.php
public function forgotPassword(Request $request){
$data['user']['email'] = $request->input('user.email');
Mail::send('vendor.notifications.resetpassword', $data, function($message) use($data){
$message->from('bemsadmin@gmail.com');
$message->to($data ['user']['email']);
$message->subject('Your Email');
});
return response()->json($data);
}
resetpassword.blade.php
<!DOCTYPE html>
<html>
<body>
<p>{{$data['user']['email']}}</p>
</body>
</html>
答案 0 :(得分:0)
发生错误是因为您没有将名为$data
的变量传递到电子邮件视图,
您传递这样的变量
Mail::send('vendor.notifications.resetpassword', ['data' => $data], function($message) use($data){
但是随着您的代码传递的是
['user' => ['email' => 'email@examle.com']]
因此请尝试使用以下代码,它应该可以完成工作。
{{$user['email']}}