File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 46
46
*/
47
47
'use_cursor_pagination ' => false ,
48
48
49
+ /*
50
+ * use simpleFastPaginate() or fastPaginate from https://github.com/hammerstonedev/fast-paginate
51
+ * use may installed it via `composer require hammerstone/fast-paginate`
52
+ */
53
+ 'use_fast_pagination ' => false ,
54
+
49
55
/*
50
56
* Here you can override the base url to be used in the link items.
51
57
*/
Original file line number Diff line number Diff line change 2
2
3
3
namespace Spatie \JsonApiPaginate ;
4
4
5
+ use Composer \InstalledVersions ;
5
6
use Illuminate \Database \Eloquent \Builder as EloquentBuilder ;
6
7
use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
7
8
use Illuminate \Database \Eloquent \Relations \HasManyThrough ;
@@ -38,7 +39,15 @@ protected function registerMacro()
38
39
$ paginationParameter = config ('json-api-paginate.pagination_parameter ' );
39
40
$ paginationMethod = config ('json-api-paginate.use_cursor_pagination ' )
40
41
? 'cursorPaginate '
41
- : (config ('json-api-paginate.use_simple_pagination ' ) ? 'simplePaginate ' : 'paginate ' );
42
+ : (
43
+ config ('json-api-paginate.use_simple_pagination ' )
44
+ ? (config ('json-api-paginate.use_fast_pagination ' ) ? 'simpleFastPaginate ' : 'simplePaginate ' )
45
+ : (config ('json-api-paginate.use_fast_pagination ' ) ? 'fastPaginate ' : 'paginate ' )
46
+ );
47
+
48
+ if (config ('json-api-paginate.use_simple_pagination ' ) && !InstalledVersions::isInstalled ('hammerstone/fast-paginate ' )) {
49
+ abort (500 , 'You need to install hammerstone/fast-paginate to use fast pagination. ' );
50
+ }
42
51
43
52
$ size = (int ) request ()->input ($ paginationParameter .'. ' .$ sizeParameter , $ defaultSize );
44
53
$ cursor = (string ) request ()->input ($ paginationParameter .'. ' .$ cursorParameter );
You can’t perform that action at this time.
0 commit comments