Laravel 更新密码验证

Laravel Update password validation

我有一个编辑表单,用户将在其中输入他的新密码,我想检查输入的密码是否与数据库中已存在的密码匹配,如果匹配则出现错误 "New Password cannot be same as old password"

这是我试过的代码,但它对我不起作用!! :(

if(\Hash::check($request->password,$old_password)){
    return Redirect::back()->withErrors(['message', 'New Password cannot be same as old password']);
}
if (Hash::check("ValueForEnteredpassword", "HashOldPassword")) { 
      //your code  
    }   else { 
    //Your error message 
    }

我想你可以试试这个例子:

if(!Hash::check($input['current_password'], $user->password)){

   dd('Return error with current passowrd is not match.');

}else{

   dd('Write here your update password code');

}

希望这个例子适合你!!!