query-filter-laravel icon indicating copy to clipboard operation
query-filter-laravel copied to clipboard

Default Pagination Limit

Open nafiesl opened this issue 5 years ago • 3 comments

Hi @LIQRGV, I am using this package and try to fetch 13k records, and they loaded as my expectation. But I think it would be nice if we have a default pagination limit. I am thinking some of these terms:

  • We can set a default limit value in a config file.
  • The default pagination limit is null, means no limit.
  • We can create a child RequestParser class, and override the pagination limit with a class property.
<?php

namespace App\Http\Requests;

use Illuminate\Http\Request;
use LIQRGV\QueryFilter\RequestParser;

class BrowseInvoice extends RequestParser
{
    protected $pageLimit = 50;

    public function __construct(Request $request)
    {
        parent::__construct($request);
    }
}

nafiesl avatar Feb 09 '20 13:02 nafiesl

I think we can use some kind of trait of interface. Like trait HasPagination or interface Paginationable and check that availability on the parser.

With that, we will extend it like this

public class ChildRequestParser extends RequestParser implement Paginationable {
.......
}

On the controller, it will be something like this

public function index(ChildRequestParser $parser) {
    $builder = $parser->getBuilder();
    // do something with builder
    .............
}

How's that sounds ?

LIQRGV avatar Nov 29 '22 13:11 LIQRGV

Looks good, @LIQRGV let me know if you need any help implementing it.

nafiesl avatar Nov 29 '22 13:11 nafiesl

So, we will implement something like this. https://github.com/SpartnerNL/Laravel-Excel/blob/3.1/src/Sheet.php#L209 We will check presence of Paginationable on the request class, wdyt @nafiesl ?

LIQRGV avatar Nov 30 '22 10:11 LIQRGV