<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\AdminAuth\LoginRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AdminAuthenticateController extends Controller
{
    
    public function aict(){

    	if(Auth::guard('admin')->check()){
    		return redirect('/admin');
    	}
    	return view('Admin.login');
    }

    public function login(LoginRequest $request){
    	if(Auth::guard('admin')->attempt(['email'=>$request->email,'password'=>$request->password])){
    		return redirect('/admin');
    	}else{
            return redirect('/aict.py')->with('error_message' , 'Your Username or Password is incorrect');
        }
    }


    public function logout(){
    	Auth::guard('admin')->logout();
    	return redirect('/aict.py');
    }

}
