isAgentPortal() ? collect() : User::query()->orderBy('username')->get(['id', 'username']); return view('admin.dashboard.index', [ 'portal' => $this->portal(), 'agents' => $agents, ]); } public function data(Request $request) { $data = $this->stats->collect([ 'date_from' => trim((string) $request->query('date_from', '')), 'date_to' => trim((string) $request->query('date_to', '')), 'date_range' => trim((string) $request->query('date_range', '')), 'range' => (string) $request->query('range', 'today'), 'channel_id' => trim((string) $request->query('channel_id', '')), 'agent_user_id' => $this->isAgentPortal() ? null : AgentScope::parseAgentUserIdFilter($request->query('agent_user_id')), 'agent' => $this->agent(), ]); return response()->json([ 'code' => 0, 'msg' => '', 'data' => $data, ]); } }