aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-10-23 17:54:23 +0200
committerWilly Micieli <micieli@laposte.net>2019-10-23 17:54:23 +0200
commitb51681ccd0bddd262a587b1635e7cf3090d1fc10 (patch)
treefe71722b1697faf183591e012af2775ecb24d116
parentb1d92286ee3607eec4a2601f8f34f0989a98eb7f (diff)
downloadimperium-b51681ccd0bddd262a587b1635e7cf3090d1fc10.zip
imperium-b51681ccd0bddd262a587b1635e7cf3090d1fc10.tar.gz
fix pagination bug
-rw-r--r--imperium/Html/Pagination/Pagination.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/imperium/Html/Pagination/Pagination.php b/imperium/Html/Pagination/Pagination.php
index 1b214e4..5ee303e 100644
--- a/imperium/Html/Pagination/Pagination.php
+++ b/imperium/Html/Pagination/Pagination.php
@@ -56,6 +56,7 @@
$this->total = $total;
$this->pages = intval(ceil($total / $limit)) + 1;
$this->url = config('pagination', 'url');
+
}
/**
@@ -68,8 +69,12 @@
*/
public function paginate() : string
{
-
+
+ if (superior_or_equal($this->limit,$this->total))
+ return '';
+
$html = '<nav aria-label="Page navigation"><ul class="' . config('pagination', 'ul_class') . '">';
+
for($i = 1; $i != $this->pages; $i++)
$i === $this->current_page ? append($html, '<li class="' . config('pagination', 'li_class') . ' active"><a href="' . $this->url . $i . '" class="' . config('pagination', 'link_class') . '">' . $i . '</a></li>') : append($html, '<li class="' . config('pagination', 'li_class') . '"><a href="' . $this->url . $i . '" class="' . config('pagination', 'link_class') . '">' . $i . '</a></li>');
append($html, '</ul></nav>');