The following is a controller for users to change passwords. I want to display the "success" or "failure" information of changing passwords in the view. How should I do this?
public function update(Requests\ResetPasswordRequest $request)
{
$id=\Auth::id();
$user = User::findOrFail($id);
$oldPassword=$request->input('oldPassword');
if ($oldPassword==$user->password) {
$user->update($request->input('password'));
return redirect()->back(); //在视图中显示修改密码成功
}else{
return redirect()->back(); //在视图中显示修改密码失败
}
}
Controller:
return redirect()->back()->with('message', '修改密码成功')
View: