Why my validation is not working, but if i commend the validation, the code will successfully running. [Here is my Controller][1]
function changepassword(Request $req){
$this->validate(
$req,
[
'currpassword' => 'required | min:5',
'newpassword' => 'required | min:5',
'confirmnewpassword' => 'required| same:newpassword |min:5'
]);
// Validasinya gajalan
$id = $req->input('id');
$data = User::find($id);
$currpassword = $req->input('currpassword');
$newpassword = $req->input('newpassword');
$confirmnewpassword = $req->input('confirmnewpassword');
$currpass = $req->input('currpassword'); // password yang lama
$currpasshash = Hash::make('currpassword');
if (Hash::check($currpass , $data->password)) {
$data->password = Hash::make($newpassword);
$data->save();
return redirect('profile');
}
else{
return redirect('changepassword');
}
}