From b3efed8ab779805b3c10f3d0700e091dcb1a0550 Mon Sep 17 00:00:00 2001 From: Sheikh Heera Date: Fri, 9 Jun 2017 22:05:53 +0600 Subject: [PATCH] Fixed a minor bug. --- src/Requent/Traits/QueryBuilderMethods.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Requent/Traits/QueryBuilderMethods.php b/src/Requent/Traits/QueryBuilderMethods.php index 5a82b64..4c6f61d 100644 --- a/src/Requent/Traits/QueryBuilderMethods.php +++ b/src/Requent/Traits/QueryBuilderMethods.php @@ -26,10 +26,7 @@ public function fetch($id = null, $columns = ['*']) public function get($columns = ['*']) { if(($perPage = $this->perPage()) || $this->isPaged()) { - $pagination = $this->getQueryStringValue( - $this->getConfigValue('paginator_identifier') - ); - return $this->callPaginate($pagination, $perPage, $columns); + return $this->callPaginate($perPage, $columns); } return $this->transform($this->builder->get($columns)); } @@ -116,19 +113,30 @@ protected function perPage() /** * Call the appropriate pagination method - * @param String $pagination Pagination Type * @param Int $perPage * @param Array $columns * @return Mixed */ - protected function callPaginate($pagination, $perPage, $columns) + protected function callPaginate($perPage, $columns) { - if($pagination != 'simple') { + if($this->getPaginator() != 'simple') { return $this->paginate($perPage, $columns); } return $this->simplePaginate($perPage, $columns); } + /** + * Determine the paginator to be used + * @return Array + */ + protected function getPaginator() + { + $paginator = $this->getQueryStringValue( + $this->getConfigValue('paginator_identifier') + ); + return $paginator ?: $this->getConfigValue('default_paginator'); + } + /** * Normalize the method parameters * @param Int $perPage