Skip to content

Commit 9e74206

Browse files
committed
Add the query builder as the first parameter
1 parent f530201 commit 9e74206

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/DataTableResponder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -196,24 +196,24 @@ private function manipulateCollection($results)
196196
* Make response meta
197197
*
198198
* If a callable is given as an element value then
199-
* the result collection is passed to it as the first
200-
* parameter
199+
* the query and collection as parameters
201200
*
202201
* `disallow_ordering_by` will always be overwritten
203202
* as it is managed internally
204203
*
204+
* @param Builder $query
205205
* @param Collection $collection
206206
* @return array
207207
*/
208-
private function makeMeta(Collection $collection)
208+
private function makeMeta(Builder $query, Collection $collection)
209209
{
210210
$meta = $this->meta;
211211
$out = [];
212212

213213
foreach($meta as $element => $value) {
214214
if (is_callable($value)) {
215215
$out[$element] = call_user_func_array(
216-
$value, [$collection]
216+
$value, [$query, $collection]
217217
);
218218

219219
continue;
@@ -265,7 +265,7 @@ public function respond()
265265

266266
$results = $this->paginateQuery($query);
267267
$results = $this->manipulateCollection($results);
268-
$meta = $this->makeMeta($results->getCollection());
268+
$meta = $this->makeMeta($query, $results->getCollection());
269269

270270
return DataTableResponse::success($results, $meta)->json();
271271
}

0 commit comments

Comments
 (0)