/** * 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'); }
/** * Create a new DepartmentStaff instance after a valid registration. * * @param array $data * @return DepartmentStaff */ protected function create(array $data) { return DepartmentStaff::create(['id' => $data['id'], 'dCode' => $data['dCode'], 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'firstLogin' => true]); }
/** * Remove a departmentStaff * * @param $id * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ public function removeDepartmentStaff($id) { if ($id != null) { DepartmentStaff::destroy($id); } return redirect('admins/manage/departmentStaffs'); }
/** * 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'); }