*/ public function latestActiveMapByBagCode(int $lgIdx): array { $rows = $this->where('pu_lg_idx', $lgIdx) ->where('pu_state', 1) ->orderBy('pu_regdate', 'DESC') ->orderBy('pu_idx', 'DESC') ->findAll(); $map = []; foreach ($rows as $row) { $code = (string) ($row->pu_bag_code ?? ''); if ($code === '' || isset($map[$code])) { continue; } $map[$code] = $row; } return $map; } }