@@ -106,6 +106,16 @@ public function make($mDataSupport = true): JsonResponse
106106 }
107107 }
108108
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+
109119 /**
110120 * Prepare query by executing count, filter, order and paginate.
111121 *
@@ -123,7 +133,7 @@ protected function prepareQuery(): static
123133
124134 $ this ->prepared = true ;
125135
126- return $ this ;
136+ return $ this ;
127137 }
128138
129139 /**
@@ -146,9 +156,10 @@ public function prepareCountQuery(): QueryBuilder
146156 $ builder = clone $ this ->query ;
147157
148158 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 ());
152163 }
153164
154165 $ row_count = $ this ->wrap ('row_count ' );
@@ -182,16 +193,6 @@ protected function wrap(string $column): string
182193 return $ this ->getConnection ()->getQueryGrammar ()->wrap ($ column );
183194 }
184195
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-
195196 /**
196197 * Keep the select bindings.
197198 *
@@ -309,6 +310,16 @@ protected function getBaseQueryBuilder($instance = null)
309310 return $ instance ;
310311 }
311312
313+ /**
314+ * Get query builder instance.
315+ *
316+ * @return QueryBuilder
317+ */
318+ public function getQuery (): QueryBuilder
319+ {
320+ return $ this ->query ;
321+ }
322+
312323 /**
313324 * Resolve the proper column name be used.
314325 *
@@ -524,20 +535,6 @@ public function orderByNullsLast(): static
524535 return $ this ;
525536 }
526537
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-
541538 /**
542539 * Perform pagination.
543540 *
@@ -558,6 +555,20 @@ public function paging(): void
558555 }
559556 }
560557
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+
561572 /**
562573 * Add column in collection.
563574 *
@@ -778,14 +789,4 @@ public function getFilteredQuery(): QueryBuilder
778789
779790 return $ this ->getQuery ();
780791 }
781-
782- /**
783- * Get query builder instance.
784- *
785- * @return QueryBuilder
786- */
787- public function getQuery (): QueryBuilder
788- {
789- return $ this ->query ;
790- }
791792}
0 commit comments