Skip to content

Commit

Permalink
Add pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
NastuzziSamy committed Nov 10, 2022
1 parent 17af353 commit 25d49ae
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Traits/Http/Requests/HasLaramoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,14 @@ public function resolvePagination()
public function resolveModels()
{
if ($this->filterMeta()->doesPaginate()) {
$this->resolvePagination()->getCollection();
$pagination = $this->resolvePagination();

header('Pagination-Count: '. $pagination->perPage());
header('Pagination-Page: '. $pagination->currentPage());
header('Pagination-Limit: '. $pagination->lastPage());
header('Pagination-Total: '. $pagination->total());

return $pagination->getCollection();
}

return $this->generateModelQuery()->get();
Expand Down Expand Up @@ -258,11 +265,7 @@ public function model()
public function models()
{
if (\is_null($this->models)) {
if ($this->filterMeta()->doesPaginate()) {
$this->pagination();
} else {
$this->models = $this->getModels();
}
$this->models = $this->getModels();
}

return $this->models;
Expand Down

0 comments on commit 25d49ae

Please sign in to comment.