Skip to content

Commit 2889680

Browse files
authored
Fix MongoDB throwing error when perPage is string
Hello, we're using MongoDB in our Laravel project and it seems to require strictly integer type when passing the limit for pagination. Whenever you attempt to change Per Page in frontend it will replace `$perPage` to a string type and when `render` function calls `paginate` it will throw error. This pull request fixes it, but not sure if it is the right place where to type cast.
1 parent d36f332 commit 2889680

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/TableComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function render(): View
9696
{
9797
return view($this->view(), [
9898
'columns' => $this->columns(),
99-
'models' => $this->paginationEnabled ? $this->models()->paginate($this->perPage) : $this->models()->get(),
99+
'models' => $this->paginationEnabled ? $this->models()->paginate((int)$this->perPage) : $this->models()->get(),
100100
]);
101101
}
102102

0 commit comments

Comments
 (0)