From f3b4de58e8c1013812173b2bc57968895a5c875b Mon Sep 17 00:00:00 2001 From: always18 Date: Sat, 29 Jun 2019 12:04:43 +0530 Subject: [PATCH] Fix bug in paginate method in Builder.php Laravel has facility to pass columns (having clause columns define in select) in paginate method but it won't pass it to getCountForPagination() method which requires columns which can come from paginate method. Due to this, it is not able to add having clause in first count agreegator query hit to get total no of records. --- src/Illuminate/Database/Eloquent/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Builder.php b/src/Illuminate/Database/Eloquent/Builder.php index 670f7409f073..7ac2fb5096b5 100755 --- a/src/Illuminate/Database/Eloquent/Builder.php +++ b/src/Illuminate/Database/Eloquent/Builder.php @@ -747,7 +747,7 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $perPage = $perPage ?: $this->model->getPerPage(); - $results = ($total = $this->toBase()->getCountForPagination()) + $results = ($total = $this->toBase()->getCountForPagination($columns)) ? $this->forPage($page, $perPage)->get($columns) : $this->model->newCollection();