<?php

namespace App\Http\Controllers\Admin\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    public function index()
    {
        return view('admin.auth.login');
    }

    public function login(Request $request)
    {
        $credentials = $request->only('email', 'password');

        if (auth()->attempt($credentials)) {
            return redirect()->route('admin.dashboard.index');
        }

        return back()->with('error', 'Giriş bilgileri hatalı.');
    }

    public function logout()
    {
        auth()->logout();

        return redirect()->route('login.index');
    }
}
