This might work as basic pagination logic?
TOTAL_ROWS = select count(*) from table;
PAGES = TOTAL_ROWS / PAGE_SIZE # (set PAGE_SIZE to the number of rows to show in a screen "page"
if( (PAGES x PAGE_SIZE) < TOTAL_ROWS) PAGES++; # capture the last few rows that dont fill the last page completely
Page=1; Start at first page #
LastID=0; First row is 1 so >0 logic starts at 1 in SQL
#repeat this part
ROWS = select * from table where id > LastID orderby ID LIMIT PAGE_SIZE
foreach(ROWS as ROW)
LastID=ROW->id;
So you now have a page full of data in ROWS, the last row ID used for the next SQL fetch.
For the Page selection you could store the row ID of the first row in an array so if you need to fetch back a random page you can decrement by 1 and re-fetch from there.
Laravel should have a Pagination facility that does this or most of this, look into "chunck" command...
Sid