From bf6433af3bb0079ee1e34c41a5d70f81ed36777d Mon Sep 17 00:00:00 2001 From: objec Date: Thu, 11 Jun 2026 23:05:24 +0400 Subject: [PATCH] Supplier model: - Add optional columns array to allow functions to optionally select a subset of columns for faster queries. Signed-off-by: objec --- app/Models/Supplier.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 1a1e94fcc..47387d62c 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -88,17 +88,15 @@ class Supplier extends Person } } - /** - * Gets information about multiple suppliers - */ - public function get_multiple_info(array $person_ids): ResultInterface + public function getMultipleInfo(array $personIds, array $columns = []): array { - $builder = $this->db->table('suppliers'); - $builder->join('people', 'people.person_id = suppliers.person_id'); - $builder->whereIn('suppliers.person_id', $person_ids); - $builder->orderBy('last_name', 'asc'); - - return $builder->get(); + $builder = $this->db->table('suppliers') + ->join('people', 'people.person_id = suppliers.person_id') + ->whereIn('suppliers.person_id', $personIds); + if (!empty($columns)) { + $builder->select(implode(', ', $columns)); + } + return $builder->get()->getResultArray(); } /**