diff --git a/change-log.md b/change-log.md index bd425ae3..eaee740e 100644 --- a/change-log.md +++ b/change-log.md @@ -8,6 +8,11 @@ ##Change Log +###v5.11.1 + - Collection engine enhancement. + - Add support for filtering compound key PR #146. + - Add support for ordering using compound key. + ###v5.11.0 - Add support for rendering view directly on addColumn and editColumn. diff --git a/src/yajra/Datatables/Engines/CollectionEngine.php b/src/yajra/Datatables/Engines/CollectionEngine.php index 28620bae..8c24f487 100644 --- a/src/yajra/Datatables/Engines/CollectionEngine.php +++ b/src/yajra/Datatables/Engines/CollectionEngine.php @@ -12,6 +12,7 @@ use Closure; use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Str; use yajra\Datatables\Contracts\DataTableEngine; @@ -98,7 +99,7 @@ public function ordering() function ($row) use ($column) { $row = Helper::castToArray($row); - return $row[$column]; + return Arr::get($row, $column); } ); @@ -123,15 +124,14 @@ function ($row) use ($columns) { $keyword = $this->request->keyword(); foreach ($this->request->searchableColumnIndex() as $index) { $column = $this->getColumnName($index); - - if ( ! array_key_exists($column, $data)) { + if ( ! $value = Arr::get($data, $column)) { continue; } if ($this->isCaseInsensitive()) { - $found[] = Str::contains(Str::lower($data[$column]), Str::lower($keyword)); + $found[] = Str::contains(Str::lower($value), Str::lower($keyword)); } else { - $found[] = Str::contains($data[$column], $keyword); + $found[] = Str::contains($value, $keyword); } }