Skip to content

Commit f927a74

Browse files
authored
Merge pull request #1759 from yajra/patch-with
[8.0] Add withQuery api for query callback.
2 parents 5c9a9d3 + 304aef9 commit f927a74

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/DataTableAbstract.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,28 @@ public function with($key, $value = '')
340340
if (is_array($key)) {
341341
$this->appends = $key;
342342
} elseif (is_callable($value)) {
343-
$this->appends[$key] = $value;
343+
$this->appends[$key] = value($value);
344344
} else {
345345
$this->appends[$key] = value($value);
346346
}
347347

348348
return $this;
349349
}
350350

351+
/**
352+
* Add with query callback value on response.
353+
*
354+
* @param string $key
355+
* @param callable $value
356+
* @return $this
357+
*/
358+
public function withQuery($key, callable $value)
359+
{
360+
$this->appends[$key] = $value;
361+
362+
return $this;
363+
}
364+
351365
/**
352366
* Override default ordering method with a closure callback.
353367
*

0 commit comments

Comments
 (0)