query-filter-laravel
query-filter-laravel copied to clipboard
Default Pagination Limit
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);
}
}
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 ?
Looks good, @LIQRGV let me know if you need any help implementing it.
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 ?