I want to display a table of users in my application, the maximum rows the table shows is 25 row, so instead of retrieving the 1500 user at once, i used chunk method to chunk the results by 25 row, but it returns an empty response.
DB::table('users')->orderBy('id')->chunk(25, function (Collection $users) {
return response()->json([
'users' => $users
]);
});