Jump to content

how to perform database query pagination and split results in addon module?


weelow

Recommended Posts

Hello,

as per whmcs, we should refer to Larvael database documentation.

https://laravel.com/docs/master/pagination

i tried to do it to split the query results over several pages and use the pagination generate links function to do it easily. I keep getting errors every time i replace the ->get(); with ->paginate(20);

there is a work around of course to create a code that would paginate but i wanted to take advantage of how it is done in larvael.

Any help is appreciated.

Thanks,

 

Link to comment
Share on other sites

You could try looking at this thread.

As far as I know Laravel pagination is not included in WHMCS but most importatly «pagination operations that use a groupBy statement cannot be executed efficiently by Laravel. If you need to use a groupBy with a paginated result set, it is recommended that you query the database and create a paginator manually»

I would laugh if it wasn't so sad.

Edited by Kian
Link to comment
Share on other sites

Thanks Kian,

you are right. it seems whmcs is using larvael 5.2 and pagination was not in that version as per documentation. It was only available starting version 5.3
https://laravel.com/docs/5.2/queries

the only way to do it is using limit & offset and using loops to create the pages and links
https://laravel.com/docs/5.2/queries#ordering-grouping-limit-and-offset

I will post the way i did it on the link you shared so i can share it with the community.

Link to comment
Share on other sites

  • 2 years later...

Hi weelow, 

 

can you help me with pagination for two custom hooks, what shows data from the same database but different table, I have a pagination in place but in address bar is adding me https://whmcs.instance/clientarea.php?action=productdetails&id=50&pageno=3 and if I switch to other hook what take information from the same db but other table is checking from the page 3 not from the page 1.

it is anything you can do ? or give me an advice. who did the pagination for me is unavailable at the moment to have a look.

 

thanks,
Alex

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated