Skip to content

Commit

Permalink
Make paginator's meta information to be properly casted.
Browse files Browse the repository at this point in the history
Paginated collection's meta information such as `current_page`, `last_page`, `from`, `to`, `total` and `per_page` will be casted to integer. Add `.idea` directory to `.gitignore`
  • Loading branch information
iraklisg committed Aug 3, 2020
1 parent b4ce964 commit 94d8562
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
/.idea
.phpunit.result.cache
docker-compose.override.yml
docker-compose.yml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "culturegr/presenter",
"version": "1.0.1",
"version": "1.0.2",
"description": "Eloquent Model Presenter for Laravel applications",
"license": "MIT",
"authors": [
Expand Down
14 changes: 7 additions & 7 deletions src/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public static function pagination(Paginator $paginator): Collection
'next' => $paginator->nextPageUrl(),
],
'meta' => [
'current_page' => $paginator->currentPage(),
'from' => $paginator->firstItem(),
'last_page' => $paginator->lastPage(),
'current_page' => (int) $paginator->currentPage(),
'from' => (int) $paginator->firstItem(),
'last_page' => (int) $paginator->lastPage(),
'path' => $paginator->path(),
'per_page' => $paginator->perPage(),
'to' => $paginator->lastItem(),
'total' => $paginator->total(),
'per_page' => (int) $paginator->perPage(),
'to' => (int) $paginator->lastItem(),
'total' => (int) $paginator->total(),
]
]);
}
Expand Down Expand Up @@ -138,4 +138,4 @@ protected function whenLoaded(string $relationship)

return $this->model->$relationship;
}
}
}

0 comments on commit 94d8562

Please sign in to comment.