Bom dia! Tudo está funcionando normal aqui conforme a aula, porém não entendi como o store() do LoginController está sendo executado - visto que não definimos um action no formulário de login.
Por que o store() está sendo executado?
index.blade.php:
<x-layout title="login">
<form method="post">
@csrf
<div class="form-group text-light">
<label for="email" class="form-label">E-mail</label>
<input type= "email" name="email" id="email" class="form-control">
</div>
<div class="form-group text-light">
<label for="password" class="form-label">Password</label>
<input type= "password" name="password" id="password" class="form-control">
</div>
<button class="btn btn-primary mt-3">
Entrar
</button>
</form>
</x-layout>
LoginController:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class LoginController
{
public function index()
{
return view('login.index');
}
public function store(Request $request)
{
if (!Auth::attempt($request->all()));
}
}
Rotas:
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\SeriesController;
use App\Http\Controllers\SeasonsController;
use App\Http\Controllers\EpisodesController;
use Illuminate\Http\Request;
use App\Http\Middleware\Autenticador;
use App\Http\Controllers\LoginController;
Route::get('/', function () {
return redirect('series');
})->middleware(Autenticador::class);
Route::resource('/series', SeriesController::class)
->except(['show']);
Route::get('/series/{series}/seasons', [SeasonsController::class, 'index'])->name('seasons.index');
Route::get('/seasons/{season}/episodes', [EpisodesController::class, 'index'])->name('episodes.index');
Route::post('/seasons/{season}/episodes', [EpisodesController::class, 'update'])->name('episodes.update');
Route::get('/login', [LoginController::class, 'index'])->name('login');
Route::post('/login', [LoginController::class, 'store'])->name('signin');