<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\ContactMessage;
use App\Models\Content;
use App\Models\Testimonial;
use Illuminate\View\View;

class DashboardController extends Controller
{
    public function __invoke(): View
    {
        return view('admin.dashboard', [
            'blogCount' => Content::query()->ofType(Content::TYPE_BLOG)->count(),
            'guideCount' => Content::query()->ofType(Content::TYPE_GUIDE)->count(),
            'newsCount' => Content::query()->ofType(Content::TYPE_NEWS)->count(),
            'messagesUnread' => ContactMessage::query()->whereNull('read_at')->count(),
            'testimonialCount' => Testimonial::query()->count(),
            'latestMessages' => ContactMessage::query()->latest()->limit(5)->get(),
        ]);
    }
}
