123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace App\Http\Controllers\TeacherAuth;
- use App\Http\Controllers\Controller;
- use Illuminate\Foundation\Auth\AuthenticatesUsers;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Http\Request;
- use App\User;
- class LoginController extends Controller
- {
-
-
- public $redirectTo = '/teacher_profile';
-
- public function __construct()
- {
- $this->middleware('teacher.guest', ['except' => 'logout']);
- }
-
- 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('/login-v2')->with('error','Unknown Email address!');
- }else{
- if($teacher->apply_status == 0){
- return redirect('/login-v2')->with('error', 'Account Approve Status is not Activated!');
- }
- else{
- $credentials = [
- 'email' => $request->email,
- 'password' => $request->password,
- 'apply_status' => '1',
- 'status' => '1',
- ];
- if (Auth::guard('teacher')->attempt($credentials)) {
- return redirect('teacher_profile');
- }
- else{
- return redirect('/login-v2')->with('error','Wrong Email/Password combination');
- }
- }
- }
- }
- public function logout(){
- $this->guard('teacher')->logout();
- request()->session()->invalidate();
- return redirect('/login-v2');
- }
-
- protected function guard()
- {
- return Auth::guard('teacher');
- }
- }
|