<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
    function login_page()
    {
        return view( view_page('login'));
    }

    function login_user(Request $request)
    {
            $this->validate($request, ['email' => 'required', 'password' => 'required' ]);
            $confirm_user = Auth::attempt(request(['email', 'password']), true );
            if (!$confirm_user): return error_msg('Invalid Login Details' ); endif; 
            send_login_email();
            return redirect()->route('dashboard'); 
    }
}
