guard('teacher'); } public function username() { return 'phone'; } public function login(Request $request) { $validator = Validator::make($request->all(), [ $this->username() => 'required|string', 'password' => 'required|string' ]); if($validator->fails()) { return back()->withErrors($validator); } // If the class is using the ThrottlesLogins trait, we can automatically throttle // the login attempts for this application. We'll key this by the username and // the IP address of the client making these requests into this application. if ($this->hasTooManyLoginAttempts($request)) { $this->fireLockoutEvent($request); return $this->sendLockoutResponse($request); } if ($this->attemptLogin($request)) { return $this->sendLoginResponse($request); } // If the login attempt was unsuccessful we will increment the number of attempts // to login and redirect the user back to the login form. Of course, when this // user surpasses their maximum number of attempts they will get locked out. $this->incrementLoginAttempts($request); return $this->showWarning('密码或者手机错误', ['url' => '/teacher/login']); // return $this->sendFailedLoginResponse($request); } public function logout() { Auth::guard('teacher')->logout(); return redirect('/teacher/login'); } public function showChangePasswordForm(Request $request) { return view('teacher.auth.change-password'); } public function changePassword(Request $request) { $teacher = Auth::guard('teacher')->user(); if(!empty($request->input('password'))) { $teacher->password = bcrypt($request->input('password')); $teacher->save(); } return $this->showMessage('操作成功'); } }