How to use Laravel pagination and still able to export all records

759 Views Asked by At

I'm working on a project and have added around 1500 entries to the user's table. However, I've noticed that the loading time of my website has increased as a result. To display the user records and allow for exporting to PDF, CSV, and Excel, I'm utilizing datatables. My dilemma is that if I use Laravel pagination, I won't be able to download all the records through the datatable export function. Is there a way to use pagination and still be able to export all or selected records in Laravel?

After using the Laravel pagination and I clicked to export, Only the first ten rows are exported with the datatables. I want to have all the records exported.

1

There are 1 best solutions below

0
cengsemihsahin On

Did you see this package yajra/laravel-datatables-export ? Maybe it can work for you. It uses databases very efficiently. However, if your project has reached a certain stage and is working, it may be very difficult for you to switch to this structure.

Instead, you can customize the export button and have it throw a request. In this request, you can make all the data exportable and reflect it to the client user.