<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\MidtransController;

Route::get('/test', function () {
    return 'Hello API, you are alive!';
});

// Endpoint untuk registrasi, login, dan verifikasi
Route::post('/register', [AuthController::class, 'register']);
Route::post('/verify-otp', [AuthController::class, 'verifyOtp']);
Route::post('/login', [AuthController::class, 'login']);
Route::post('/midtrans/notification', function () {
    // Jika rute ini berhasil dipanggil, kita akan log pesan ini.
    \Illuminate\Support\Facades\Log::info('WEBHOOK NOTIFICATION RECEIVED!');

    // Dan kita akan kirim respons sukses.
    return response()->json(['message' => 'API route is alive and well!'], 200);
});
// Endpoint yang dilindungi (harus login untuk akses)
Route::middleware('auth:sanctum')->group(function () {
    // Mengambil data user yang sedang login
    Route::get('/user', function (Request $request) {
        return $request->user()->load('profile'); // Mengambil data user & profilnya
    });

    // Logout
    Route::post('/logout', [AuthController::class, 'logout']);

});