File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77use Windwalker \Query \Query ;
88
9- readonly class QueryPaginate
9+ class QueryPaginate
1010{
11+ public \Closure $ nextHandler {
12+ get => $ this ->getNextHandler ();
13+ }
14+
15+ protected string |\Closure $ cursorField ;
16+
1117 public function __construct (
1218 public int $ length ,
1319 /**
14- * @var \Closure(Query $query): ?Query
20+ * @var string| \Closure(Query $query): ?Query
1521 */
16- public \Closure $ nextHandler ,
22+ \Closure | string $ cursorField
1723 ) {
24+ $ this ->cursorField = $ cursorField ;
25+ }
26+
27+ protected function getNextHandler (): \Closure
28+ {
29+ $ field = $ this ->cursorField ;
30+
31+ if (is_string ($ field )) {
32+ $ field = static function (Query $ query , object |array $ item ) use ($ field ) {
33+ if (is_array ($ item )) {
34+ $ cursor = $ item [$ field ];
35+ } else {
36+ $ cursor = $ item ->{$ field };
37+ }
38+
39+ return $ query ->where ($ field , '> ' , $ cursor );
40+ };
41+ }
42+
43+ return $ field ;
1844 }
1945}
You can’t perform that action at this time.
0 commit comments