更改密码用户 laravel 5.3
我想用 3 个字段(old_password、new_password、confirm_password)创建带有 laravel 5 的表单。
视图
旧密码 :{!! Form::password('old_password',['class' => 'form-control']) !!}
新密码 :{!! Form::password('password',['class' => 'form-control']) !!}
确认新密码 :{!! Form::password('verify_password',['class' => 'form-control']) !!}
用户注册时的控制器
public function postRegister(Request $request)
{
$rules = [
'email' => 'required|email|unique:users',
'confirm_email' => 'required|same:email',
'password' => 'required|min:8|regex:/^(?=\S*[a-z])(?=\S*[!@#$&*])(?=\S*[A-Z])(?=\S*[\d])\S*$/',
'verify_password' => 'required|same:password',
];
$messages = [
'email.required' => 'email tidak boleh kosong',
'password.required' => 'password tidak boleh kosong',
'password.min' => 'Password harus minimal 8 karakter',
'password.regex' => 'Format password harus terdiri dari kombinasi huruf besar, angka dan karakter spesial (contoh:!@#$%^&*?><).',
'verify_password.required' => 'Verify Password tidak boleh kosong',
'email.email' => 'Format Email tidak valid',
'email.unique' => 'Email yang anda masukkan telah digunakan',
'verify_password.same' => 'Password tidak sama!',
];
$this->validate($request,$rules,$messages);
$newUser = $this->user->create([
'email' => $request->email,
'password' => \Hash::make($request->password),
]);
$this->activationService->sendActivationMail($newUser);
return redirect('/account/login')->with('success', 'Check your email');
}
我是laravel的新手,我读过一些类似的问题来更改堆栈溢出中的密码,但它没有帮助我。
我应该如何在控制器中编写代码以更改密码用户?提前致谢。