From 3a34cf7bb09b44ff5f51f048c70eb62484c5f7ca Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 23 Nov 2018 11:20:42 +0800 Subject: [PATCH] Fix adding of index column. Introduced on #1852. --- src/Processors/DataProcessor.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Processors/DataProcessor.php b/src/Processors/DataProcessor.php index 8d61d950..9126e516 100644 --- a/src/Processors/DataProcessor.php +++ b/src/Processors/DataProcessor.php @@ -56,11 +56,6 @@ class DataProcessor */ protected $includeIndex; - /** - * @var string - */ - protected $indexColumn; - /** * @var array */ @@ -100,8 +95,6 @@ public function __construct($results, array $columnDef, array $templates, $start public function process($object = false) { $this->output = []; - $indexColumn = config('datatables.index_column', 'DT_RowIndex'); - foreach ($this->results as $row) { $data = $this->escapeRow(Helper::convertToArray($row)); $value = $this->addColumns($data, $row); @@ -141,8 +134,10 @@ protected function addColumns($data, $row) */ protected function addIndexColumn($data) { + $indexColumn = config('datatables.index_column', 'DT_RowIndex'); + if ($this->includeIndex) { - $data[$this->indexColumn] = ++$this->start; + $data[$indexColumn] = ++$this->start; } return $data;