From be57292115af30779fda4d91aa0768182b1ca0a9 Mon Sep 17 00:00:00 2001 From: neoan Date: Sun, 10 Nov 2024 14:31:08 -0500 Subject: [PATCH] Expand pagination --- .github/workflows/testing.yml | 2 +- src/Model/Model.php | 5 +++++ src/Model/Paginate.php | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ed64406..acb56d0 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -69,7 +69,7 @@ jobs: color: ${{ env.BADGE_COLOR }} path: '.github/badges/test-badge.svg' - name: Upload badge as artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: badge path: '.github/badges/test-badge.svg' diff --git a/src/Model/Model.php b/src/Model/Model.php index 125604a..421d47f 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -76,6 +76,11 @@ public static function retrieve(array $condition = [], array $filter = []): Coll { self::interpret(); $select = self::$tableName . '.' . self::$interpreter->getPrimaryKey(); + foreach ($condition as $key => $value) { + if(str_contains($key, '.')) { + $select .= ' ' . $key; + } + } $results = Database::easy($select, $condition, $filter); $collection = new Collection(); diff --git a/src/Model/Paginate.php b/src/Model/Paginate.php index 6eb89ed..261fe5b 100644 --- a/src/Model/Paginate.php +++ b/src/Model/Paginate.php @@ -53,6 +53,11 @@ public function get(): array $modelDescription = $this->model::declare(); $table = array_key_first($modelDescription); $select = $table . '.' . $modelDescription[$table][0]['name']; + foreach ($condition as $key => $value) { + if(str_contains($key, '.')) { + $select .= ' ' . $key; + } + } $total = count(Database::easy($select, $this->condition)); $start = ($this->page - 1) * $this->pageSize; $callFunctions = [];