下面给出了我更改密码的代码。请帮我打印'您的密码已成功更改'。
public function passwordupdate(Request $request){
$user=user::find(Auth::user()->id);
$validator=Validator::make($request->all(), [
'password' => 'required|min:6|max:14',
'password_confirmation' => 'required|min:6|max:14',
]);
if($validator->fails()){
return redirect()->back()->withErrors(['password'=>'Please check the password you given']);
}else if (!Hash::check($request->cpassword, Auth::user()->password)) {
return redirect()->back()->withErrors(['password'=>'Error!!Please check the current password you given']);
}
else{
$user->password=bcrypt($request->password);
$user->save();
return redirect()->back();
}
}
答案 0 :(得分:0)
您可以使用Flash消息返回给用户。
而不是
return redirect()->back();
你可以做到
return redirect()->back()->with('message', 'your password has changed successfully');
然后在您的刀片文件中显示消息
@if( Session::has('message') )
<div class="alert">{{ Session::get('message') }}</div>
@endif
答案 1 :(得分:0)
您还可以使用Laravel的Flash Data功能。代码如下:
$request->session()->flash('message', 'Password Changed Successfully!');
return redirect()->back();
您可以在视图中检索消息,如下所示:
@if( Session::has('message') )
<div class="alert">{{ Session::get('message') }}</div>
@endif
希望它有所帮助.. !!