<?php

namespace App\Http\Controllers\SupportTeam;

use App\Http\Controllers\Controller;
use App\Models\SupportTicket;
use Illuminate\View\View;

class SupportTeamDashboardController extends Controller
{
    public function __invoke(): View
    {
        return view('support-team.dashboard', [
            'totalTickets' => SupportTicket::count(),
            'openTickets' => SupportTicket::where('status', SupportTicket::STATUS_OPEN)->count(),
            'pendingTickets' => SupportTicket::where('status', SupportTicket::STATUS_PENDING)->count(),
            'answeredTickets' => SupportTicket::where('status', SupportTicket::STATUS_ANSWERED)->count(),
            'closedTickets' => SupportTicket::where('status', SupportTicket::STATUS_CLOSED)->count(),
            'urgentTickets' => SupportTicket::where('priority', SupportTicket::PRIORITY_URGENT)->count(),
            'latestTickets' => SupportTicket::with('user')->latest()->take(6)->get(),
        ]);
    }
}
