我是一名初学者 Web 开发人员 我正在尝试编写一个条件,该条件将根据用户将发送的数据来满足如果条件达到 100% 但其他条件会产生以下文本的错误
试图获取非对象的属性“unique_id”
如果有人知道如何解决这个问题,我将不胜感激
这是我来自控制器的代码
public function checkRestorePassword(Request $request)
{
$result['success'] = false;
$rules = [
'unique_id' => 'required',
];
$validation = Validator::make($request->all(), $rules);
if (empty($validation))
{
$result['error'] = "Enter the code that was sent to you by mail.";
return response()->json($result, 422);
}
$user = User::where('unique_id', $request->uniqueId)->first();
if ($user->unique_id === $request->uniqueId)
{
$result['success'] = 'Access to your personal account successfully restored. Please change your password.';
return response()->json($result, 200);
}
else
{
$result['success'] = false;
return response()->json($result, 422);
}
}
蝴蝶不菲