/**
* 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
];
}
Created
June 15, 2016 16:41
-
-
Save hootlex/2b0594370e1a5c21dff50ccead84a32e 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