MacsiDigital / laravel-zoom

Laravel Zoom Package
MIT License
261 stars 135 forks source link

Pagination value is ignored/ does not work #106

Open SuperDJ opened 3 years ago

SuperDJ commented 3 years ago

The ->paginate() value is ignored:

When calling:

dd(Zoom::user()
    ->where( 'status', 'active' )
     ->paginate( 10 )->get());

This is the result:

MacsiDigital\API\Support\ResultSet {#2651 ▼
  #apiTotalRecords: 20
  #apiPerPage: 10
  #apiCurrentPage: 1
  #apiLastPage: 2
  #apiPagesDownloaded: array:1 [▶]
  #totalRecords: 20
  #perPage: 50
  #currentPage: 1
  #lastPage: 1
  #pagesDownloaded: array:1 [▶]
  #hasOwnMeta: true
  #paginationMethod: "fresh"
  #items: Illuminate\Support\Collection {#2672 ▶}
  #downloaded: 10
  #raw: false
  #all: false
  #queries: 0
  #maxQueries: "5"
  #builder: MacsiDigital\API\Support\Builder {#2315 ▶}
  #responses: array:1 [▶]
  #resource: MacsiDigital\Zoom\User {#2649 ▶}
}

Now the result has 10 (downloaded) users but laravel thinks there are 50 (perPage). This is also a problem for JS components. For example the result in Vue looks like: image

Also using ->setPerPage does not help. It still returns with perPage 50.

$perPage = 10;
return Zoom::user()
        ->where( 'status', 'active' )
          ->paginate( $perPage )
          ->setPerPage( $perPage )
          ->get();