【发布时间】:2019-04-13 20:29:33
【问题描述】:
*在 null 时调用成员函数 notify()? *Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) 在 null 上调用成员函数 notify()
*Controllers\UserController.php
public function store3(Request $request)
{
$request->session()->flush();
return redirect('home');
}
public function check(Request $request)
{
$request->validate( [ ' => 'required|string|max:255', ]);
$student_id = $request->input('student_id');
$query = DB::select("SELECT * FROM `users` WHERE `student_id` =
'$student_id'") ;
return view('auth.studentregistraionStatus',['query'=>$query]);
}
public function notificationmail(Request $request)
{
$student_id = session('student_id');
$user = User::where('id','=','1')->first();
$user->notify(new registration_details("Your application number is :- $student_id" ));
return view('auth.studentregistration4');
}
【问题讨论】:
-
看起来
$user为空。User::where('id','=','1')不应该使用$student_id吗? -
很抱歉,请您说明一下要删除的内容和添加的内容,谢谢 nigel
-
试试
$user = User::where('id','=',$student_id)->first(); -
您没有将 student_id 放在 session 中显示的代码中的任何位置...您在哪里制作
session(['student_id' => $request->input('student_id')]); -
请努力改进你的代码风格,这样读起来很难。