From 74b3bb42eafaecd4cd437b43810711b5abc20fd7 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Tue, 9 Jan 2024 23:35:11 -0300 Subject: [PATCH] Add sorting to fetchAll --- app/common/Ideal/Repository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/Ideal/Repository.php b/app/common/Ideal/Repository.php index 3322bf5..18a4237 100644 --- a/app/common/Ideal/Repository.php +++ b/app/common/Ideal/Repository.php @@ -45,11 +45,14 @@ abstract class Repository implements Define\Repository ->where("{$this->getKey()} = ?"); return $this->fetchOne($query, [$id]); } - public function fetchAll(): array + public function fetchAll(null|string|array $ordering = null): array { $query = $this->connection->getQueryBuilder() ->select() ->from($this->getTable()); + if ($ordering !== null) { + $query->order($ordering); + } return $this->fetchMany($query); }