我正在处理应用程序,我收到了这个notify()错误



*在null时调用成员函数notify((?*Symfony\Component\Debug\Exception\FatalThrowableError(E_ERROR(调用空上的成员函数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');
}

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
}

最新更新