title: Laravel pagination get next page
body: <p>I have a an api which will fetch data that is paginated by 10 items. Here's my logic:</p>
  
  <pre><code>public function getGamesResult(Request $request)
  {
      // Validations
      $rules = [
          'from'=&gt;'required|string',
          'to'=&gt; 'required|string'
      ];
  
      $validator = Validator::make($request-&gt;all(), $rules);
  
      if ($validator-&gt;fails()) {
  
          // Validation failed
          return response()-&gt;json([
              'success' =&gt; false,
              'message' =&gt; $validator-&gt;messages(),
          ]);
      }
  
      $params =  $request-&gt;all();
  
      $games = Game::whereBetween("game_date", [$params["from"], $params["to"]])-&gt;paginate(10);
      $result = [];
  
      foreach ($games as $game) {
  
          $win_data = [];
          $winners = $game-&gt;result()-&gt;get();
  
          // Get Winning Number Records
          foreach ($winners as $win)
          {
              $winning_numbers_arr = explode(',', $win-&gt;winning_numbers);
  
  
              $win_data[] = [
                  'game_id' =&gt; $win-&gt;game_id,
                  'created_dt' =&gt; $win-&gt;created_dt
              ];
  
          }
  
          $result[] = [
              'game_data' =&gt; [
              'game_id' =&gt; $game-&gt;id,
              'game_date' =&gt; $game-&gt;game_date
          ],
              'winning_number' =&gt; $win_data
          ];
      }
  
      return response()-&gt;json([
          'success' =&gt; true,
          'data' =&gt; $result,
          'total'=&gt; $games-&gt;total(),
          'count'=&gt; $games-&gt;count(),
          'hasMorePages'=&gt; $games-&gt;hasMorePages(),
          'currentPage'=&gt; $games-&gt;currentPage()
      ]);
  }
  </code></pre>
  
  <p>My question is how do laravel knows when I want to fetch the next 10 records? Or am I doing it wrong? If there are total of 3000 records, how will I get the next page using this same logic?</p>