<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Http\Request;
use Hash;
use Session;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;

class LoginController extends BaseController
{
    
    
    public function admin_login_form(){

        return view('admin.users.auth-login')
        ->with('pageHeading', 'Admin Login');
    }
    public function admin_login(Request $request){
        if (Auth::check()) {
            return Redirect::to('admin/dashboard');
        }else{
            $request->validate([
                'email' => 'required',
                'password' => 'required',
            ]);
    
            $credentials = $request->only('email', 'password');
            //print_r($credentials ); exit;
            if (Auth::attempt($credentials)) {
                return Redirect::to('admin/dashboard');
            }else{
                echo 'test'; exit;
            }
        }
  
        
    }
}
