From 6f821bcf24950b58e633cb0cac7bbee6acb0f34a Mon Sep 17 00:00:00 2001 From: Jarek Tkaczyk Date: Sat, 22 Apr 2017 22:38:11 +0800 Subject: [PATCH] fixed pagination query on searchable builder --- src/Query/Builder.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Query/Builder.php b/src/Query/Builder.php index 0e60add..f461e48 100644 --- a/src/Query/Builder.php +++ b/src/Query/Builder.php @@ -87,4 +87,20 @@ protected function restoreFieldsForCount() $this->backups = $this->bindingBackups = []; } + + /** + * Run a pagination count query. + * + * @param array $columns + * @return array + */ + protected function runPaginationCountQuery($columns = ['*']) + { + $bindings = $this->from instanceof Subquery ? ['order'] : ['select', 'order']; + + return $this->cloneWithout(['columns', 'orders', 'limit', 'offset']) + ->cloneWithoutBindings($bindings) + ->setAggregate('count', $this->withoutSelectAliases($columns)) + ->get()->all(); + } }