0
    $rowsPerPage = 50;
    $num = 1;
    $offsets = ($num - 1) * $rowsPerPage;

    $data['trans'] = Transaction::withoutBranch()
    ->select('id', 'amount')
    ->where('payment_date', '>=', '2019-06-07')
    ->limit($offsets)
    ->get();

I'm using Laravel 4.2 to do the planning. I trying to get the data from data with 50 on the first page then the second page will get another new 50 data.

I did try the code but it still gets all of the data from the database.

Ghanshyam Nakiya
  • 1,077
  • 11
  • 18
rajoh
  • 17
  • 3
  • 2
    Possible duplicate of [Laravel Eloquent limit and offset](https://stackoverflow.com/questions/35643192/laravel-eloquent-limit-and-offset) – 4givN Jun 07 '19 at 12:52

1 Answers1

1

Please try following:

$data['trans'] = Transaction::withoutBranch()
    ->select('id', 'amount')
    ->where('payment_date', '>=', '2019-06-07')
    ->limit($rowsPerPage)
    ->offset($offsets)
    ->get();
Dhara Bhatti
  • 239
  • 2
  • 6