laraDev98's avatar

Laravel Package chumper/datatables fetches the entire table every time it is called.How can I add skip() and take() to it?

I'm using Chumper/Datatable https://github.com/Chumper/Datatable

This is the code that I'm using to get json response for displaying the table.

$query = Article::select('title','id','created_at')->orderBy('id','desc')->get();

Datatable::collection($query)
    ->addColumn('id', function($model){
        return $model->id;
    })
    ->addColumn('title', function ($model) { return $model->accomodation ; })
    ->addColumn('created_at', function($model){
        return  Carbon::parse($model->created_at)->toFormattedDateString();
    })
    ->searchColumns('title', 'id')
    ->orderColumns('created_at','title','id')
    ->make();
    ````
    
I tried a lot to add skip and take to this package but nothing seems to be working.Do you guys have know any idea to add efficient pagination without modifying the core jquery plugin or  core of chumper/datatable?

Hope you guys will help!
0 likes
0 replies

Please or to participate in this conversation.