Skip to content

Instantly share code, notes, and snippets.

@Sekaiichi
Created December 6, 2021 12:59
Show Gist options
  • Save Sekaiichi/9dcc0bd6cdbf448eed6d12c7335bfe9a to your computer and use it in GitHub Desktop.
Save Sekaiichi/9dcc0bd6cdbf448eed6d12c7335bfe9a to your computer and use it in GitHub Desktop.
public function respondPagination(LengthAwarePaginator $awarePaginator, JsonResource $resourceForMap = null): JsonResponse
{
if (!is_null($resourceForMap)) {
$items = $resourceForMap->collection($awarePaginator->items());
} else {
$items = $awarePaginator->items();
}
return $this->respond([
'pagination' => $this->getPagination($awarePaginator),
'items' => $items,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment