<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\IftaQuestion;
use App\Models\IftaReply;
use App\Models\SitePage;
use App\Models\User;
use Illuminate\View\View;

class DashboardController extends Controller
{
    public function __invoke(): View
    {
        return view('admin.dashboard', [
            'counts' => [
                'users' => User::count(),
                'questions' => IftaQuestion::count(),
                'replies' => IftaReply::count(),
                'pages' => SitePage::count(),
            ],
            'latestQuestions' => IftaQuestion::with('user')->latest()->limit(5)->get(),
        ]);
    }
}
