After adding Paginate() to your eloquent result or your repository
you'll get data paginated and you can show your pagination details in resource :
To make your code clean make a PaginationResource to be used across different collections and make single place for editing pagination details
then inside any resource add your Pagination resource as follow
this is Pagination resource
public function toArray($request) : Array
{
return [
'total' => $this->total(),
'count' => $this->count(),
'per_page' => $this->perPage(),
'current_page' => $this->currentPage(),
'total_pages' => $this->lastPage()
];
}
and add it to any other collection like this
public function toArray($request) : Array
{
$pagination = new PaginationResource($this);
return [
'templates' => $this->collection,
$pagination::$wrap => $pagination,
];
}