如您所见,我在$tabname
中声明了一个带有空值的变量function accountsettings()
。用户在我的视图文件中提交表单后,它将转到function changepassword()
。用户提交表单后,我试图更改$tabname
的值。
public function accountsettings()
{
$tabname = " ";
return view('account_settings')->with("tabName", $tabname);
}
public function changepassword(Request $request, $id)
{
// $this->validate($request, [
// 'newPassword' => 'required|confirmed|min:6',
// ]);
$user = Auth::user();
$tabname = "password";
$curPassword = $request->post('oldPassword');
$newPassword = $request->post('newPassword');
if (Hash::check($curPassword, $user->password)) {
$user_id = $user->id;
$obj_user = User::find($user_id)->first();
$obj_user->password = Hash::make($newPassword);
}
else
{
}
return redirect()->route('account_settings')->with("tabName", $tabname);
}
我的视图中有多个选项卡。.我要的是,一旦用户在特定选项卡中提交了表单,在页面加载后它将保留在该选项卡上。我在我的视图class="nav-link {{ empty($tabName) || $tabName == 'password' ? 'active' : '' }}"
中添加了此代码,这就是为什么一旦用户提交表单后,我就要更改$ tabname的值。任何帮助,将不胜感激。谢谢。