<?php

namespace App\Livewire;

use App\Models\User;
use App\Models\Contractor;
use App\Models\JobPackage;
use App\Models\Contract;
use Livewire\Component;

class AdminStatistics extends Component
{
    public $totalUsers;
    public $totalContractors;
    public $totalPackages;
    public $totalContracts;
    public $verifiedOAP;
    public $draftContracts;
    public $completedContracts;
    public $activePackages;

    public function mount()
    {
        $this->totalUsers = User::count();
        $this->totalContractors = Contractor::count();
        $this->totalPackages = JobPackage::count();
        $this->totalContracts = Contract::count();
        $this->verifiedOAP = Contractor::where('oap_status', 'verified')->count();
        $this->draftContracts = Contract::where('status', 'draft')->count();
        $this->completedContracts = Contract::where('status', 'completed')->count();
        $this->activePackages = JobPackage::where('status', 'active')->count();
    }

    public function render()
    {
        return view('livewire.admin-statistics');
    }
}