<?php

namespace Modules\Main\Http\Controllers\Company;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Main\Models\Agent\Agent;
use Modules\Main\Models\Agent\AgentStatus;
use Modules\Main\Models\Company\CompanyAdmin;
use Modules\Main\Models\City;

class AgentsTableController extends Controller
{
    public function index(Request $request)
    {
        $agents = Agent::where('company_id', GetAvailableAgents());
        switch ($request->status) {
            case AgentStatus::DISMISSED:
                $agents->whereNotNull('deleted_at');
                break;
            default:
                $agents->withTrashed();
        }

        return view('main::company.agents.table', [
            'status' => $request->status,
            'cities' => City::all()
        ])->with('statuses', AgentStatus::class);
    }
}
