Skip to content

Commit

Permalink
Enable ->params
Browse files Browse the repository at this point in the history
  • Loading branch information
yidas committed May 29, 2023
1 parent d6b95bb commit 23a875e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/data/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Pagination
*
* @var array
*/
public $params;
public $params = [];

/**
* Total number of items
Expand Down Expand Up @@ -183,8 +183,10 @@ public function createUrl($page, $perPage=null)
if ($this->perPageParam) {
$params[$this->perPageParam] = ($perPage) ? $perPage : $this->perPage;
}
// Verify $this->params
$this->params = is_array($this->params) ? $this->params : [];
// Build URL
$url = "//{$_SERVER['HTTP_HOST']}{$requestUri}?" . http_build_query(array_merge($_GET, $params));
$url = "//{$_SERVER['HTTP_HOST']}{$requestUri}?" . http_build_query(array_merge($_GET, $this->params, $params));

return $url;
}
Expand Down
3 changes: 3 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

$pagination = new \yidas\data\Pagination([
'totalCount' => $count,
'params' => [
'key' => 'value',
],
]);

?>
Expand Down

0 comments on commit 23a875e

Please sign in to comment.