Skip to content

Commit

Permalink
Merge pull request #41 from MediciVN/feature/update-method-ApiRespons…
Browse files Browse the repository at this point in the history
…er-trait

update responseCursorPagination
  • Loading branch information
duyngha authored Jul 25, 2022
2 parents bf43519 + 470c3c6 commit 1785a6c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Traits/ApiResponser.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,21 @@ public function errorResponse(string $code, string $message = '', array $errorDe
return response()->json($response, $codeBag[0]);
}

/**
* @param CursorPaginator $paginator
/**
* @param string|null $nextCursor
* @param string|null $previousCursor
* @param array $items
* @return JsonResponse
*/
public function responseCursorPagination(CursorPaginator $paginator): JsonResponse
public function responseCursorPagination(string $nextCursor = null, string $previousCursor = null, array $items = []): JsonResponse
{
$response = [
'success' => true,
'next_cursor' => $paginator->nextCursor()?->encode(),
'prev_cursor' => $paginator->previousCursor()?->encode(),
'data' => $paginator->items(),
'next_cursor' => $nextCursor,
'prev_cursor' => $previousCursor,
'data' => $items
];

return response()->json($response);
}
}
}

0 comments on commit 1785a6c

Please sign in to comment.