Question:
How to use start and limit on DataTables in Laravel for mobile API?

Solution

The following code will help you use start and limit on DataTables in Laravel for mobile API. 


public function listRemarks(ListRequest $request)

{

    $query = $this->remarkservice->listRemarks($request);

    $totalRecords = $query->count();

    $limit = $request->input('length') ?? 10;

    $start = $request->input('start') ?? 0;


    $listRemarks = $query->skip($start)->take($limit)->get();

    $filterRecords = $query->count();


    return DataTables::of($listRemarks)

        ->setTotalRecords($totalRecords)

        ->setFilteredRecords($filterRecords)

        ->toJson();

}


Suggested blogs:

>How to download an entire S3 bucket - Complete Guide

>How to get item details of Woo Commerce in custom email content?

>How to install Laravel using composer and configure?

>How to make a single result from a database using MySQL?

>How to Make New Model/Controller/Migration in Laravel?

>How to make non-programmers to run a Python program?


Ritu Singh

Ritu Singh

Submit
0 Answers