Page 7 - Modul CRUD Laravel_Neat
P. 7
class AuthController extends Controller
{
public function login(Request $request)
{
$user = $request->username;
$pass = $request->password;
$data = DB::table('user')->where('username', $user)-
>where('password', $pass)->first();
if($data) {
return redirect('barang');
}else{
return redirect('/')-
>with('alert', 'Username atau Password Salah!');
}
}
}
14. Set routing juga, buka file web.php pada directory ~/crud-laravel/routes/
Kemudian tambahkan pada baris paling bawah kode berikut:
Route::post('/login', [AuthController::class, 'login']);
Coba dites login