<?php

namespace Modules\Admin\App\Livewire\Users;

use Modules\Admin\App\Models\User;

use Livewire\Component;

class UserCount extends Component
{
    public $total, $enabled, $disabled;

    protected $listeners = ['refreshUserCount' => 'updateCounts'];

    public function mount()
    {
        $this->updateCounts();
    }

    public function updateCounts()
    {
        $this->total = User::count();
        $this->enabled = User::where('status', User::STATUS_ENABLED)->count();
        $this->disabled = User::where('status', User::STATUS_DISABLED)->count();
    }

    public function render()
    {
        return view('admin::livewire.users.user-count');
    }
}
