<filename>app/Http/Controllers/LoginController.php<?php

namespace App\Http\Controllers;

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

class LoginController extends Controller
{
    public function index()
    {
        if (Auth::check())
            return redirect('/principal');


        $title = 'CyberAcademy';
        return view('login.index', compact('title'));
    }

    public function form_login()
    {
        return "Formulario de login";
    }

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

        if (Auth::attempt($credentials)) {
            // Authentication passed...
            return redirect()->intended('dashboard');
        }
    }
}
