How can I implement Laravel's cursor paginator without returning the id column in the collection?
The following query:
'users' => User::cursorPaginate(15)
returns the individual users like this:
{
"id": 1,
"uuid": "376bec76-9095-4510-a5ba-fea0f234c6cf",
"username": "alexanderhorner",
"password": "$2y$12$qMITOdMr2XdAq3EMKwc/WeB/db9IaQdkZ5egqY7CX5WpUwwHLKOLK"
}
Now, lets say I have an API. I want api/v1/user to return the same paginated results using cursorPaginate(), but I don't want to return the id column.
'users' => User::select('uuid', 'username')->cursorPaginate(15)
would return an error though, since cursorPaginate() needs the ID column or something similar:
InvalidArgumentException
Illegal operator and value combination.
What's the best way to fix this? Filter the collection returned by cursorPaginate()?