/** * Update the password * * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @throws \Illuminate\Foundation\Validation\ValidationException */ public function updatePassword(Request $request) { // Validate the password length $validator = $this->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } // Get the currently logged departmentStaff $departmentStaff = DepartmentStaff::find(Auth::guard('departmentStaff')->user()->id); $newPassword = $request['password']; $departmentStaff->password = bcrypt($newPassword); $departmentStaff->firstLogin = false; $departmentStaff->save(); return redirect('/departmentStaffs/home'); }
/** * Update user password * * @param Request $request * @return mixed */ public function updatePassword(Request $request) { // Get the logged in user $departmentStaff = DepartmentStaff::find(Auth::guard('departmentStaff')->user()->id); $newPassword = $request['password']; // Validate the password $this->validate($request, ['password' => 'required|min:8']); // Save updated password $departmentStaff->password = bcrypt($newPassword); $departmentStaff->save(); return redirect()->back()->with('status', 'Success'); }