I’m trying to get data, using this query
$game->teams()->orderByRaw('CASE WHEN position IS NULL THEN 0 ELSE 1 END DESC')->orderBy('position')->with(['user'])->get()
it has the correct results and orders,
but when I try to paginate it, of course by replacing ->get()
with ->paginate(15)
, now the data is incorrect.
some data in top 15 when using get()
isn’t there anymore when using paginate
, and supposedly, the results when using get()
are distinct, but on paginate
, some items are still present in page 2.
btw, i have this orderByRaw('CASE WHEN position IS NULL THEN 0 ELSE 1 END DESC')
query to put null positions
to last.