Hi everyone, my issue is to change the pagination number in browse view.
Actually is showing 15 records per page, but i want change it to more.
Where can i find that variable? Searching for it but not find it.
Regards.
There is currently no way to change the number of results per page. The code is using the default value for results-per-page. For reference, here's the code: https://github.com/the-control-group/voyager/blob/1.0/src/Http/Controllers/VoyagerBreadController.php#L69 $getter is "paginate", and it's called without arguments.
I found out a workaround: you can set a new value of $perpage property in Model definition. For example, I have a Company.php file that has:
class Company extends Model
{
protected $perPage = 50;
// other code
}
A way to dynamically set the per-page pagination limit is by adding this to your model's constructor:
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->perPage = request()->input('show') ?? 50;
}
Then you can change your query string to be ?show=100 and 100 records will be displayed. Of course you are free to change show to your preferred query string. count or whatever.
You could take this a step further and modify the browse blade template and add an input field to set the show query string with an integer value to give users the ability to set the pagination to whatever they want.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
I found out a workaround: you can set a new value of $perpage property in Model definition. For example, I have a Company.php file that has:
class Company extends Model { protected $perPage = 50; // other code }