middleware('teacher.guest', ['except' => 'logout']); } /** * Show the application's login form. * * @return \Illuminate\Http\Response */ public function showLoginForm() { return view('login-v2'); } public function login(Request $request) { $teacher = User::where('user_type',2)->where('email',$request->email)->first(); if(!$teacher){ return redirect('/')->with('error','Unknown Email address!'); }else{ if($teacher->status == '0'){ return redirect('/')->with('error', 'Account Status is not Activated!'); } else{ $credentials = [ 'email' => $request->email, 'password' => $request->password, 'status' => '1' ]; if (Auth::guard('teacher')->attempt($credentials)) { return redirect('teacher_profile'); } else{ return redirect('/')->with('error','Wrong Email/Password combination'); } } } } public function logout(){ $this->guard('teacher')->logout(); request()->session()->invalidate(); return redirect('/login-v2'); } /** * Get the guard to be used during authentication. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard('teacher'); } }