Laravel's Illuminate Paginator Can't Find Query String

I'm working on a old PHP project, that is running in legacy SQL query, which is good but I like to use query builders like Laravel Illuminate SQL package!

So i have added all required package dependencies to run Illuminate SQL, and this query builder seems to work fine with pagination!

$users = Capsule::table('users')->paginate(1)->toArray();

But, the paginator seems not to be able to listen the query string! For example, by running the above code it would give some properties like, next_page , previous_page etc...

enter image description here

And when I try to pass the query string in the URL it can't fetch the data from query string(From the GET request)!

Visiting this page would give the same result set.

How i should configure the Illuminate sql package so it can also listen to the query strings?


Also, i've tried to use the illuminate/http package, but the $request->all() method always returns an empty array! Here is the code:

  require_once './vendor/autoload.php';
  use \Illuminate\Http\Request;

  $req = new Request();

  echo '<pre>';
  echo '</pre>';

It returns empty input data array, enter image description here

What i am missing to use the http package, any idea would be helpful.



You have to set a page resolver:

\Illuminate\Pagination\Paginator::currentPageResolver(function ($pageName = 'page') {
    return (int) ($_GET[$pageName] ?? 1);

Laravel uses this resolver.