You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -131,6 +131,8 @@ $model = YourModel::find(1);
131
131
$model->relation()->jsonPaginate();
132
132
```
133
133
134
+
### Override default behavior
135
+
134
136
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`.
135
137
136
138
```php
@@ -139,6 +141,24 @@ $maxResults = 60;
139
141
YourModel::jsonPaginate($maxResults);
140
142
```
141
143
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
+
142
162
### Cursor pagination
143
163
144
164
This package also supports cursor pagination, which can be briefly defined by the Laravel Framework as follows:
0 commit comments