@@ -106,6 +106,16 @@ public function make($mDataSupport = true): JsonResponse
106
106
}
107
107
}
108
108
109
+ /**
110
+ * Get paginated results.
111
+ *
112
+ * @return \Illuminate\Support\Collection<int, array>
113
+ */
114
+ public function results (): Collection
115
+ {
116
+ return $ this ->query ->get ();
117
+ }
118
+
109
119
/**
110
120
* Prepare query by executing count, filter, order and paginate.
111
121
*
@@ -123,7 +133,7 @@ protected function prepareQuery(): static
123
133
124
134
$ this ->prepared = true ;
125
135
126
- return $ this ;
136
+ return $ this ;
127
137
}
128
138
129
139
/**
@@ -146,9 +156,10 @@ public function prepareCountQuery(): QueryBuilder
146
156
$ builder = clone $ this ->query ;
147
157
148
158
if ($ this ->isComplexQuery ($ builder )) {
149
- $ table = $ this ->getConnection ()->raw ('( ' .$ builder ->toSql ().') count_row_table ' );
150
-
151
- return $ this ->getConnection ()->table ($ table )->setBindings ($ builder ->getBindings ());
159
+ return $ this ->getConnection ()
160
+ ->query ()
161
+ ->fromRaw ('( ' .$ builder ->toSql ().') count_row_table ' )
162
+ ->setBindings ($ builder ->getBindings ());
152
163
}
153
164
154
165
$ row_count = $ this ->wrap ('row_count ' );
@@ -182,16 +193,6 @@ protected function wrap(string $column): string
182
193
return $ this ->getConnection ()->getQueryGrammar ()->wrap ($ column );
183
194
}
184
195
185
- /**
186
- * Get paginated results.
187
- *
188
- * @return \Illuminate\Support\Collection<int, array>
189
- */
190
- public function results (): Collection
191
- {
192
- return $ this ->query ->get ();
193
- }
194
-
195
196
/**
196
197
* Keep the select bindings.
197
198
*
@@ -309,6 +310,16 @@ protected function getBaseQueryBuilder($instance = null)
309
310
return $ instance ;
310
311
}
311
312
313
+ /**
314
+ * Get query builder instance.
315
+ *
316
+ * @return QueryBuilder
317
+ */
318
+ public function getQuery (): QueryBuilder
319
+ {
320
+ return $ this ->query ;
321
+ }
322
+
312
323
/**
313
324
* Resolve the proper column name be used.
314
325
*
@@ -524,20 +535,6 @@ public function orderByNullsLast(): static
524
535
return $ this ;
525
536
}
526
537
527
- /**
528
- * Paginate dataTable using limit without offset
529
- * with additional where clause via callback.
530
- *
531
- * @param callable $callback
532
- * @return $this
533
- */
534
- public function limit (callable $ callback ): static
535
- {
536
- $ this ->limitCallback = $ callback ;
537
-
538
- return $ this ;
539
- }
540
-
541
538
/**
542
539
* Perform pagination.
543
540
*
@@ -558,6 +555,20 @@ public function paging(): void
558
555
}
559
556
}
560
557
558
+ /**
559
+ * Paginate dataTable using limit without offset
560
+ * with additional where clause via callback.
561
+ *
562
+ * @param callable $callback
563
+ * @return $this
564
+ */
565
+ public function limit (callable $ callback ): static
566
+ {
567
+ $ this ->limitCallback = $ callback ;
568
+
569
+ return $ this ;
570
+ }
571
+
561
572
/**
562
573
* Add column in collection.
563
574
*
@@ -778,14 +789,4 @@ public function getFilteredQuery(): QueryBuilder
778
789
779
790
return $ this ->getQuery ();
780
791
}
781
-
782
- /**
783
- * Get query builder instance.
784
- *
785
- * @return QueryBuilder
786
- */
787
- public function getQuery (): QueryBuilder
788
- {
789
- return $ this ->query ;
790
- }
791
792
}
0 commit comments