Преглед изворни кода

Merge pull request #1584 from jourdon/2.0

解决导出数据为数组,无模型访问器问题
Jiang Qinghua пре 3 година
родитељ
комит
4e460ce3db
1 измењених фајлова са 4 додато и 3 уклоњено
  1. 4 3
      src/Grid/Exporters/AbstractExporter.php

+ 4 - 3
src/Grid/Exporters/AbstractExporter.php

@@ -4,6 +4,7 @@ namespace Dcat\Admin\Grid\Exporters;
 
 use Dcat\Admin\Grid;
 use Illuminate\Support\Arr;
+use Illuminate\Support\Collection;
 use Illuminate\Support\Str;
 
 /**
@@ -206,7 +207,7 @@ abstract class AbstractExporter implements ExporterInterface
             $model->forPage($page, $perPage);
         }
 
-        $array = $this->grid->processFilter()->toArray();
+        $array = $this->grid->processFilter();
 
         $model->reset();
 
@@ -219,7 +220,7 @@ abstract class AbstractExporter implements ExporterInterface
      * @param  array  $data
      * @return array
      */
-    protected function normalize(array $data)
+    protected function normalize(Collection $data)
     {
         foreach ($data as &$row) {
             $row = Arr::dot($row);
@@ -256,7 +257,7 @@ abstract class AbstractExporter implements ExporterInterface
      * @param  array  $data
      * @return array
      */
-    protected function callBuilder(array &$data)
+    protected function callBuilder(Collection &$data)
     {
         if ($data && $this->builder) {
             return ($this->builder)($data);