<?php

namespace Modules\Contracts\Controllers;

use App\Controllers\BaseController;
use App\Models\CompanyModel;
use App\Models\ContractModel;

class ContractsDashboardController extends BaseController
{
    public function index()
    {
        $customerCount = (new CompanyModel())->countAllResults();
        $contractCount = (new ContractModel())->countAllResults();
        $byStatus      = (new ContractModel())->countByStatus();

        return view('Modules\Contracts\Views\dashboard\index', array_merge($this->baseViewData(), [
            'title'           => 'Contracts',
            'customerCount'   => $customerCount,
            'contractCount'   => $contractCount,
            'activeContracts' => $byStatus['active'] ?? 0,
            'draftContracts'  => $byStatus['draft'] ?? 0,
            'byStatus'        => $byStatus,
        ]));
    }
}
