/** * 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 hostelStaff $hostelStaff = HostelStaff::find(Auth::guard('hostelStaff')->user()->id); $newPassword = $request['password']; $hostelStaff->password = bcrypt($newPassword); $hostelStaff->firstLogin = false; $hostelStaff->save(); return redirect('/hostelStaffs/home'); }
/** * Update user password * * @param Request $request * @return mixed */ public function updatePassword(Request $request) { // Get the logged in user $hostelStaff = HostelStaff::find(Auth::guard('hostelStaff')->user()->id); $newPassword = $request['password']; // Validate the password $this->validate($request, ['password' => 'required|min:8']); // Save updated password $hostelStaff->password = bcrypt($newPassword); $hostelStaff->save(); return redirect()->back()->with('status', 'Success'); }