/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::paginate(20);
$data = $posts->items();
$pagination = [
'previous_page_url' => $posts->previousPageUrl(),
'next_page_url' => $posts->nextPageUrl()
];
return [
"pagination" => $pagination,
"data" => $data
];
}
-
-
Save 1stevengrant/cda92d4148017c1dbad4948e612eb344 to your computer and use it in GitHub Desktop.
pagination object API example
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment