laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Pagination does not accept string number

Open phroggyy opened this issue 6 years ago • 0 comments

Summary

When calling the ->paginate() method with the first (perPage) argument, mongodb errors if the user passes in a string.

Steps to reproduce

  1. pass per_page=20 as a query parameter on an application running this library
  2. use ->paginate($request->input('per_page')) in the called method
  3. get a Mongodb error the limit must be specified as a number

Fix

We should cast the $perPage argument to an integer before passing to mongodb; this works in the default Laravel drivers, and should work with this driver. This can be easily solved by a simple (int) cast

phroggyy avatar Apr 11 '19 20:04 phroggyy