<?php

namespace App\Livewire;

use Livewire\Component;
use Livewire\WithPagination;
use Modules\Main\Models\Company\CompanyAdmin;
use Modules\Main\Models\Agent\Agent;
use Modules\Main\Models\Agent\AgentStatus;

class AgentsTable extends Component
{
    use WithPagination;

    public $status;

    public function mount($status = null)
    {
        $this->status = $status;
    }
    public function render()
    {
        
        $agents = GetAvailableAgents('Builder');
        if ($this->status == AgentStatus::DISMISSED)
        {
            $agents->onlyTrashed();
        }
        return view(
            'livewire.agents-table',
            [
                'agents' => $agents->paginate(10)
            ]
        );
    }
    public function dismiss($id)
    {
        to_route('company.agents.delete', [
            'agent' => $id
        ]);
    }

    public function restore($id)
    {
        to_route('company.agents.restore', [
            'agent' => $id
        ]);
    }

    public function delete($id)
    {
        to_route('company.agents.delete', [
            'agent' => $id
        ]);
    }
}
