Closed jaiselrahman closed 5 years ago
Eg: Reply::where('id', 1)->orderBy('id')->cursorPaginate(3)->toArray();
Reply::where('id', 1)->orderBy('id')->cursorPaginate(3)->toArray();
Expected:
{ "data": [ ... ], "per_page": 3, "total": 1, "next_item": null, "current_page": { "direction": "after_i", "target": "1" }, "first_page": { "direction": "after_i", "target": "1" }, "last_page": null, "next_page": null, "previous_page": null, "first_page_url": "http:\/\/localhost?after_i=1", "last_page_url": null, "next_page_url": null, "prev_page_url": null, "path": "http:\/\/localhost" }
Actual:
{ "data": [ ... ], "per_page": 3, "total": 1, "next_item": null, "current_page": { "direction": "after_i", "target": "1" }, "first_page": { "direction": "after_i", "target": "1" }, "last_page": null, "next_page": { "direction": "after", "target": "1" }, "previous_page": null, "first_page_url": "http:\/\/localhost?after_i=1", "last_page_url": null, "next_page_url": "http:\/\/localhost?after=1", "prev_page_url": null, "path": "http:\/\/localhost" }
Changing to 'last' => $firstAndLast->last(), in the following line produces expected result: https://github.com/amrnn90/laravel-cursor-paginator/blob/241bc900f13b48e7e924adf9079e8ebd1cef5e7f/src/Query/QueryMeta.php#L115-L119
'last' => $firstAndLast->last(),
Thanks @jaiselrahman
Eg:
Reply::where('id', 1)->orderBy('id')->cursorPaginate(3)->toArray();
Expected:
Actual:
Changing to
'last' => $firstAndLast->last(),
in the following line produces expected result: https://github.com/amrnn90/laravel-cursor-paginator/blob/241bc900f13b48e7e924adf9079e8ebd1cef5e7f/src/Query/QueryMeta.php#L115-L119