id()) ->where('role_id', Role::COMPANY_ADMIN) ->count() == 1 ) { $companyAdmin = CompanyAdmin::where('user_id', auth()->id())->first(); return $agentsIds = Agent::where('company_id', $companyAdmin->company_id)->pluck('id'); } else { $agent = Agent::where('user_id', auth()->id())->first(); return [$agent->id]; } } public function render() { $contracts = Contract::whereHas('deal', function ($dealSubQuery) { $dealSubQuery->with('deals') ->whereIn('agent_id', $this->getSelectingAgents()); }); return view('contracts::livewire.table.index', [ 'contracts' => $contracts->get(), 'statuses' => ContractStatus::class ]); } }