Skip to content

Commit

Permalink
Merge pull request #50 from heera/requent-dev
Browse files Browse the repository at this point in the history
Requent dev
  • Loading branch information
heera authored Jun 9, 2017
2 parents da36098 + b3efed8 commit 655b9c2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/Requent/Traits/QueryBuilderMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 655b9c2

Please sign in to comment.