laravel 尝试读取数组的属性“new_password”

waxmsbnn  于 2022-12-24  发布在  其他
关注(0)|答案(1)|浏览(217)

我在执行更改登录到系统的用户的密码的方法时遇到问题,因为它无法识别数组列来更改密码。错误是Attempt to read property "new_password" on array

  • dd($validations)
array:3 [▼ // app/Http/Controllers/ChangePasswordController.php:22
      "current_password" => "12345."
      "new_password" => "67890."
      "confirm_new_password" => "67890."
    ]
  • method
public function updatePassword(ChangePasswordRequest $request)
    {
        $user = Auth::user()->name;
        $validations = $request->validated();
        User::find(Auth::user()->id)->update(['password'=> Hash::make($validations->new_password)]);
        return redirect('change_password')->with('success-update-password',"$user changed your password with sucess.");
    }
lstz6jyr

lstz6jyr1#

User::whereId(Auth::user()->id)->update(['password'=> Hash::make($validations['new_password'])]);

相关问题