laravel 更新在登录功能中不起作用
laravel update not working inside login function
// Request of email and password
$credentials = request(['email', 'password']);
// Checking credentials and increasing attempt value by 1
if (!Auth::attempt($credentials)) {
User::where('email', $request->email)->update(['attempts' => 'attempts+1']);
return response()->json([
'message' => 'Unauthorized access',
], 401);
}
以上是我在laravel 8上试过的方法。 问题 是我想在电子邮件正确且密码错误的情况下将尝试列值增加一。
if (!Auth::attempt($credentials)) {
$this->reduceAttempt($request->email);
return response()->json([
'message' => 'Unauthorized access',
], 401);
}
public function reduceAttempt($email)
{
User::where('email', $email)->update(['attempts' => DB::raw('attempts-1')]);
return $email;
}
我已经收录了DB::raw('attempts-1')
// Request of email and password
$credentials = request(['email', 'password']);
// Checking credentials and increasing attempt value by 1
if (!Auth::attempt($credentials)) {
User::where('email', $request->email)->update(['attempts' => 'attempts+1']);
return response()->json([
'message' => 'Unauthorized access',
], 401);
}
以上是我在laravel 8上试过的方法。 问题 是我想在电子邮件正确且密码错误的情况下将尝试列值增加一。
if (!Auth::attempt($credentials)) {
$this->reduceAttempt($request->email);
return response()->json([
'message' => 'Unauthorized access',
], 401);
}
public function reduceAttempt($email)
{
User::where('email', $email)->update(['attempts' => DB::raw('attempts-1')]);
return $email;
}
我已经收录了DB::raw('attempts-1')