asadali007's avatar

pagination

hello Everyone, when i run this queries they show 5 record per page but when i see queries in laravel debugger they show limit(6) why

    $flight = Flight::orderBy('id')->simplepaginate(5);

   select * from `flights` order by `id` asc limit 6 offset 0



0 likes
8 replies
asadali007's avatar

same on with cursor pagination

select * from `flights` order by `id` asc limit 6

asadali007's avatar

but work correctly use paginate

    $flight = Flight::orderBy('id')->paginate(5);

select count(*) as aggregate from `flights`
select * from `flights` order by `id` asc limit 5 offset 0
lemmon's avatar

I see what you mean I get the same thing with simplePaginate

select `threads`.*, (select count(*) from `replies` where `threads`.`id` = `replies`.`thread_id`) as `replies_count` from `threads` order by `created_at` desc limit 6 offset 0

But it works and I can't figure out why... Magic.

Please or to participate in this conversation.