From 77cd66842e2dbdee401c86427463c857b0b45c46 Mon Sep 17 00:00:00 2001 From: Stephen Nielson Date: Wed, 17 Jul 2024 22:29:15 -0600 Subject: [PATCH] Fixes #7570 list service search by codes (#7572) Fixes #7570 search for an option by the codes column --- src/Services/ListService.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Services/ListService.php b/src/Services/ListService.php index 2d118c853d3..ab3bc55f472 100644 --- a/src/Services/ListService.php +++ b/src/Services/ListService.php @@ -114,6 +114,21 @@ public function getListOption($list_id, $option_id) return null; } + /** + * Retrieves a list option for a given list by the code value + * @param string $list_id + * @param string $code The exact code(s) to match. This must match the string precisely and fuzzy matching is not currently supported. + * @return array|null + */ + public function getListOptionByCode(string $list_id, string $code) + { + $records = $this->getOptionsByListName($list_id, ['codes' => $code]); + if (!empty($records)) { // should only be one record + return $records[0]; + } + return null; + } + public function getOne($pid, $list_type, $list_id) { $sql = "SELECT * FROM lists WHERE pid=? AND type=? AND id=? ORDER BY date DESC";