Jul 14, 2024
php artisan make:controller SessionController
SessionController.php
created in app/Http/Controllers
.index.blade.php
) in resources/views/sesi
index
form.index.blade.php
in resources/views/sesi
.routes/web.php
:
Route::get('/sesi', 'SessionController@index');
Route::post('/sesi/login', 'SessionController@login');
@csrf
directive for security.Request
object.required
for email and password.Auth::attempt
.if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
return redirect()->intended('dashboard');
} else {
return back()->withErrors(['email' => 'Invalid credentials']);
}
php artisan make:seeder UsersTableSeeder
run
method.
Hash::make
for password hashing.users
table:
php artisan db:seed --class=UsersTableSeeder
register.blade.php
in resources/views/sesi
.users
table.Route::get('/sesi/logout', 'SessionController@logout');