Skip to content

Commit

Permalink
Always include 'links' in PaginatedResponse
Browse files Browse the repository at this point in the history
When working with PaginatedResponse, i feel it hard to check we have next page or not
  • Loading branch information
vanthao03596 authored and jiannei committed Apr 19, 2021
1 parent e088b0c commit 1445a6e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ protected function formatPaginatedData(array $paginated)
'count' => $paginated['to'] ?? null,
'per_page' => $paginated['per_page'] ?? null,
'current_page' => $paginated['current_page'] ?? null,
'links' => [
'previous' => $previous,
'next' => $next,
],
],
],
];
Expand All @@ -294,13 +298,6 @@ protected function formatPaginatedData(array $paginated)
$paginationInformation['meta']['pagination']['total_pages'] = $totalPages;
}

if ($previous || $next) {
$paginationInformation['meta']['pagination']['links'] = [
'previous' => $previous,
'next' => $next,
];
}

return $paginationInformation;
}

Expand Down

0 comments on commit 1445a6e

Please sign in to comment.