<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Session;
use Hash;

class AuthController extends Controller
{

    /**
     * Write code on Method
     *
     * @return response()
     */
    public function login(Request $request)
    {
        $request->validate([
            'username' => 'required',
            'password' => 'required',
        ]);

        $credentials = $request->only('UserName', 'Password');
        dd('sda');

        if (auth()->attempt($credentials)) {
            return redirect()->route('homepage');

        }else{
           session()->flash('error', 'Invalid credentials');
           return redirect()->route('login');

        }


        //return redirect("login")->withSuccess('Oppes! You have entered invalid credentials');
    }

    /**
     * Write code on Method
     *
     * @return response()
     */

}
