Skip to content

Commit edcbefd

Browse files
committed
Update usage docs
1 parent b47649b commit edcbefd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ $model = YourModel::find(1);
131131
$model->relation()->jsonPaginate();
132132
```
133133

134+
### Override default behavior
135+
134136
By default the maximum page size is set to 30. You can change this number in the `config` file or just pass the value to `jsonPaginate`.
135137

136138
```php
@@ -139,6 +141,24 @@ $maxResults = 60;
139141
YourModel::jsonPaginate($maxResults);
140142
```
141143

144+
By default the default page size is set to 30. You can change this number in the `config` file or just pass the value to `jsonPaginate`.
145+
146+
```php
147+
$defaultSize = 15;
148+
149+
YourModel::jsonPaginate(null, $defaultSize);
150+
```
151+
152+
You can also pass the total count to the `paginate` function directly. This can be useful for performance reasons or to prevent issues with `DISTINCT` keyword ([more info](https://github.com/laravel/framework/issues?q=is%3Aissue+paginate+total)).
153+
154+
⚠️ This is effective only with basic pagination (no effect with cursor, simple or fast pagination)
155+
156+
```php
157+
$total = 42;
158+
159+
YourModel::jsonPaginate(null, null, $total);
160+
```
161+
142162
### Cursor pagination
143163

144164
This package also supports cursor pagination, which can be briefly defined by the Laravel Framework as follows:

0 commit comments

Comments
 (0)