Skip to content

Commit

Permalink
Merge branch '8.0'
Browse files Browse the repository at this point in the history
* 8.0:
  Bump v8.6.1 🚀
  Fix CS.
  Fix with closue value implementation. Use filteredQuery as callback parameter. Fix #1752
  • Loading branch information
yajra committed Jun 3, 2018
2 parents 95fc21f + 5c9a9d3 commit 45b3685
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

### [Unreleased]

### [v8.6.1] - 2018-06-03

- Fix/Enhance with closure value implementation. [#1758]
- Use filteredQuery as callback parameter.
- Fix [#1752]

### [v8.6.0] - 2018-05-18

- Add support for manual setting of filtered count [#1743], credits to [@forgottencreature]
Expand Down Expand Up @@ -208,7 +214,8 @@ return (new CollectionDataTable(User::all())->toJson();
- Fix orderColumn api where related tables are not joined.
- Fix nested with relation search and sort function.

[Unreleased]: https://github.com/yajra/laravel-datatables/compare/v8.6.0...8.0
[Unreleased]: https://github.com/yajra/laravel-datatables/compare/v8.6.1...8.0
[v8.6.1]: https://github.com/yajra/laravel-datatables/compare/v8.6.0...v8.6.1
[v8.6.0]: https://github.com/yajra/laravel-datatables/compare/v8.5.2...v8.6.0
[v8.5.2]: https://github.com/yajra/laravel-datatables/compare/v8.5.1...v8.5.2
[v8.5.1]: https://github.com/yajra/laravel-datatables/compare/v8.5.0...v8.5.1
Expand Down Expand Up @@ -274,6 +281,7 @@ return (new CollectionDataTable(User::all())->toJson();
[#1737]: https://github.com/yajra/laravel-datatables/pull/1737
[#1741]: https://github.com/yajra/laravel-datatables/pull/1741
[#1743]: https://github.com/yajra/laravel-datatables/pull/1743
[#1758]: https://github.com/yajra/laravel-datatables/pull/1758

[#1626]: https://github.com/yajra/laravel-datatables/issues/1626
[#1617]: https://github.com/yajra/laravel-datatables/issues/1617
Expand All @@ -290,6 +298,7 @@ return (new CollectionDataTable(User::all())->toJson();
[#1471]: https://github.com/yajra/laravel-datatables/issues/1471
[#1739]: https://github.com/yajra/laravel-datatables/issues/1739
[#1516]: https://github.com/yajra/laravel-datatables/issues/1516
[#1752]: https://github.com/yajra/laravel-datatables/issues/1752

[laravel-datatables-fractal]: https://github.com/yajra/laravel-datatables-fractal

Expand Down
17 changes: 14 additions & 3 deletions src/DataTableAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function with($key, $value = '')
if (is_array($key)) {
$this->appends = $key;
} elseif (is_callable($value)) {
$this->appends[$key] = value($value);
$this->appends[$key] = $value;
} else {
$this->appends[$key] = value($value);
}
Expand Down Expand Up @@ -683,12 +683,12 @@ protected function processResults($results, $object = false)
*/
protected function render(array $data)
{
$output = array_merge([
$output = $this->attachAppends([
'draw' => (int) $this->request->input('draw'),
'recordsTotal' => $this->totalRecords,
'recordsFiltered' => $this->filteredRecords,
'data' => $data,
], $this->appends);
]);

if ($this->config->isDebugging()) {
$output = $this->showDebugger($output);
Expand All @@ -702,6 +702,17 @@ protected function render(array $data)
);
}

/**
* Attach custom with meta on response.
*
* @param array $data
* @return array
*/
protected function attachAppends(array $data)
{
return array_merge($data, $this->appends);
}

/**
* Append debug parameters on output.
*
Expand Down
20 changes: 20 additions & 0 deletions src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,24 @@ protected function showDebugger(array $output)

return $output;
}

/**
* Attach custom with meta on response.
*
* @param array $data
* @return array
*/
protected function attachAppends(array $data)
{
$appends = [];
foreach ($this->appends as $key => $value) {
if (is_callable($value)) {
$appends[$key] = value($value($this->getFilteredQuery()));
} else {
$appends[$key] = $value;
}
}

return array_merge($data, $appends);
}
}

0 comments on commit 45b3685

Please sign in to comment.