<?php

namespace App\Controllers;

use Config\Database;

class Home extends BaseController
{
    public function index()
    {
        try {
            $db = Database::connect();

            // Fetch all tables
            $tables = $db->listTables();

            return view('db_status_view', [
                'db_status' => true,
                'message'   => 'Database Connected Successfully',
                'tables'    => $tables
            ]);

        } catch (\Throwable $e) {
            return view('db_status_view', [
                'db_status' => false,
                'message'   => $e->getMessage(),
                'tables'    => []
            ]);
        }
    }
}
