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