<?php

namespace App\Http\Controllers\SuperAdmin;

use App\Http\Controllers\Controller;
use App\Models\Tenant;
use App\Models\User;
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
{
    public function index(): Response
    {
        $stats = [
            'total_tenants'  => Tenant::count(),
            'active_tenants' => Tenant::where('is_active', true)->count(),
            'total_users'    => User::count(),
        ];

        $recentTenants = Tenant::latest()->limit(5)->get(['id', 'name', 'slug', 'is_active', 'created_at']);

        return Inertia::render('SuperAdmin/Dashboard', [
            'stats'         => $stats,
            'recentTenants' => $recentTenants,
        ]);
    }
}
