*对成员函数notify()的调用是否为null? * Symfony \组件\调试\异常\ FatalThrowableError(E_ERROR) 在null上调用成员函数notify()
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');
}
答案 0 :(得分:0)
在users
表中,id
被声明为integer
,但是在where
子句中,您正在传递字符串。
尝试更改此内容:
...
->where('id', '=', '1')
->first();
...
对此:
...
->where('id', '=', 1)
->first();
...
当然,要使其动态化,请将1
替换为$user_id
之类的变量
此外,在通知用户之前,请确保您确实具有用户对象:
$user = // get your user
if ( ! is_null($user))
{
// Make the notification
}