瀏覽代碼

调整processFilter方法,移除toArray参数

jqh 4 年之前
父節點
當前提交
239260515c
共有 6 個文件被更改,包括 13 次插入17 次删除
  1. 2 2
      src/Grid.php
  2. 3 3
      src/Grid/Concerns/HasFilter.php
  3. 1 1
      src/Grid/Exporters/AbstractExporter.php
  4. 3 5
      src/Grid/Filter.php
  5. 3 5
      src/Grid/Model.php
  6. 1 1
      src/Support/Helper.php

+ 2 - 2
src/Grid.php

@@ -409,7 +409,7 @@ class Grid
             return;
         }
 
-        $collection = $this->processFilter(false);
+        $collection = $this->processFilter();
 
         $data = $collection->toArray();
 
@@ -609,7 +609,7 @@ HTML;
 
     protected function renderHeaderOrFooter($callbacks)
     {
-        $target = [$this->processFilter(false)];
+        $target = [$this->processFilter()];
         $content = [];
 
         foreach ($callbacks as $callback) {

+ 3 - 3
src/Grid/Concerns/HasFilter.php

@@ -30,9 +30,9 @@ trait HasFilter
      *
      * @param bool $toArray
      *
-     * @return array|Collection|mixed
+     * @return Collection
      */
-    public function processFilter($toArray = true)
+    public function processFilter()
     {
         $this->callBuilder();
         $this->handleExportRequest();
@@ -41,7 +41,7 @@ trait HasFilter
         $this->applyColumnFilter();
         $this->applySelectorQuery();
 
-        return $this->filter->execute($toArray);
+        return $this->filter->execute();
     }
 
     /**

+ 1 - 1
src/Grid/Exporters/AbstractExporter.php

@@ -212,7 +212,7 @@ abstract class AbstractExporter implements ExporterInterface
             $model->forPage($page, $perPage);
         }
 
-        $array = $this->grid->processFilter(true);
+        $array = $this->grid->processFilter()->toArray();
 
         $model->reset();
 

+ 3 - 5
src/Grid/Filter.php

@@ -619,11 +619,9 @@ class Filter implements Renderable
     /**
      * Execute the filter with conditions.
      *
-     * @param bool $toArray
-     *
-     * @return array|Collection|mixed
+     * @return Collection|mixed
      */
-    public function execute(bool $toArray = true)
+    public function execute()
     {
         $conditions = array_merge(
             $this->getConditions(),
@@ -638,7 +636,7 @@ class Filter implements Renderable
 
         $this->grid()->fireOnce(new Fetched([&$data]));
 
-        return $toArray ? $data->toArray() : $data;
+        return $data;
     }
 
     /**

+ 3 - 5
src/Grid/Model.php

@@ -350,17 +350,15 @@ class Model
     /**
      * Build.
      *
-     * @param bool $toArray
-     *
-     * @return array|Collection|mixed
+     * @return Collection
      */
-    public function buildData(bool $toArray = false)
+    public function buildData()
     {
         if (is_null($this->data)) {
             $this->setData($this->fetch());
         }
 
-        return $toArray ? $this->data->toArray() : $this->data;
+        return $this->data;
     }
 
     /**

+ 1 - 1
src/Support/Helper.php

@@ -818,7 +818,7 @@ class Helper
     public static function htmlEntityEncode($item)
     {
         if (is_array($item)) {
-            array_walk_recursive($item, function ($value) {
+            array_walk_recursive($item, function (&$value) {
                 $value = htmlentities($value);
             });
         } else {