lotteryAdmin(); abort_if($admin === null, 401); $p = AdminApiList::readPaging($request); $keyword = trim((string) $request->query('keyword', '')); $status = $request->query('status'); $scope = AdminScopePolicy::resolveContext($request, $admin); $q = Player::query() ->with([ 'wallets' => static fn ($wq) => $wq->orderBy('wallet_type')->orderBy('currency_code'), 'agentNode:id,code,name', ]) ->orderByDesc('id'); AdminScopePolicy::applyPlayerFilters($q, $scope); if ($keyword !== '') { $term = '%'.addcslashes($keyword, '%_\\').'%'; $q->where(static function ($sub) use ($term): void { $sub->where('site_player_id', 'like', $term) ->orWhere('username', 'like', $term); }); } if ($status !== null && $status !== '') { $q->where('status', (int) $status); } $paginator = $q->paginate($p['perPage'], ['*'], 'page', $p['page']); return AdminApiList::json($paginator, fn (Player $player): array => PlayerApiPresenter::listItem($player)); } }