jqh пре 6 година
родитељ
комит
6c01e0bbf6
2 измењених фајлова са 27 додато и 2 уклоњено
  1. 1 1
      src/Grid.php
  2. 26 1
      src/Grid/Row.php

+ 1 - 1
src/Grid.php

@@ -456,7 +456,7 @@ HTML
 
         if ($this->rowsCallback) {
             foreach ($this->rowsCallback as $value) {
-                $this->rows->map($value);
+                $value($this->rows);
             }
         }
     }

+ 26 - 1
src/Grid/Row.php

@@ -4,12 +4,13 @@ namespace Dcat\Admin\Grid;
 
 use Closure;
 use Dcat\Admin\Grid;
+use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Jsonable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Arr;
 
-class Row
+class Row implements Arrayable
 {
     /**
      * @var Grid
@@ -141,6 +142,18 @@ class Row
         return Arr::get($this->data, $attr);
     }
 
+    /**
+     * Setter.
+     *
+     * @param mixed $attr
+     * @param mixed $value
+     * @return void
+     */
+    public function __set($attr, $value)
+    {
+        Arr::set($this->data, $attr, $value);
+    }
+
     /**
      * Get or set value of column in this row.
      *
@@ -166,6 +179,18 @@ class Row
         return $this;
     }
 
+    /**
+     * @return array
+     */
+    public function toArray()
+    {
+        if ($this->data instanceof Arrayable) {
+            return $this->data->toArray();
+        }
+
+        return (array) $this->data;
+    }
+
     /**
      * Output column value.
      *