From 023d7da53fccf816109a1468fd2ebec49954f92b Mon Sep 17 00:00:00 2001 From: platoindebugmode Date: Mon, 9 Jun 2025 02:05:46 +0330 Subject: [PATCH] prevent division by zero in LengthAwarePaginator when $perPage is zero --- src/Illuminate/Pagination/LengthAwarePaginator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Pagination/LengthAwarePaginator.php b/src/Illuminate/Pagination/LengthAwarePaginator.php index 2a6fd8d2149c..34bb6c3eb31b 100644 --- a/src/Illuminate/Pagination/LengthAwarePaginator.php +++ b/src/Illuminate/Pagination/LengthAwarePaginator.php @@ -58,7 +58,7 @@ public function __construct($items, $total, $perPage, $currentPage = null, array $this->total = $total; $this->perPage = (int) $perPage; - $this->lastPage = max((int) ceil($total / $perPage), 1); + $this->lastPage = $this->perPage > 0 ? max((int) ceil($total / $perPage), 1) : 1; $this->path = $this->path !== '/' ? rtrim($this->path, '/') : $this->path; $this->currentPage = $this->setCurrentPage($currentPage, $this->pageName); $this->items = $items instanceof Collection ? $items : new Collection($items);