<?php

namespace App\Controllers;

use App\Models\ClientModel;
use App\Models\DeliveryNoteModel;
use App\Models\InspectionModel;
use App\Models\InspectionTemplateModel;

class DashboardController extends BaseController
{
    public function index(): string
    {
        $clients = new ClientModel();
        $templates = new InspectionTemplateModel();
        $inspections = new InspectionModel();
        $deliveryNotes = new DeliveryNoteModel();

        return view('dashboard/index', [
            'title' => 'Panel principal',
            'clientCount' => $clients->countAllResults(),
            'templateCount' => $templates->where('activo', 1)->countAllResults(),
            'inspectionCount' => $inspections->countAllResults(),
            'deliveryNoteCount' => $deliveryNotes->countAllResults(),
            'recentInspections' => $inspections->orderBy('id', 'DESC')->findAll(5),
        ]);
    }
}
