Browse Source

Form::table入库时把数据格式化为索引数组

jqh 5 years ago
parent
commit
d330717460
2 changed files with 14 additions and 12 deletions
  1. 8 6
      src/Form/Field/Table.php
  2. 6 6
      src/Traits/HasAssets.php

+ 8 - 6
src/Form/Field/Table.php

@@ -63,12 +63,14 @@ class Table extends HasMany
         $form = $this->buildNestedForm($this->column, $this->builder);
         $prepare = $form->prepare($input);
 
-        return collect($prepare)->reject(function ($item) {
-            return $item[NestedForm::REMOVE_FLAG_NAME] == 1;
-        })->map(function ($item) {
-            unset($item[NestedForm::REMOVE_FLAG_NAME]);
-            return $item;
-        })->toArray();
+        return array_values(
+            collect($prepare)->reject(function ($item) {
+                return $item[NestedForm::REMOVE_FLAG_NAME] == 1;
+            })->map(function ($item) {
+                unset($item[NestedForm::REMOVE_FLAG_NAME]);
+                return $item;
+            })->toArray()
+        );
     }
 
     protected function getKeyName()

+ 6 - 6
src/Traits/HasAssets.php

@@ -10,32 +10,32 @@ trait HasAssets
     /**
      * @var array
      */
-    protected static $script = [];
+    public static $script = [];
 
     /**
      * @var array
      */
-    protected static $style = [];
+    public static $style = [];
 
     /**
      * @var array
      */
-    protected static $css = [];
+    public static $css = [];
 
     /**
      * @var array
      */
-    protected static $js = [];
+    public static $js = [];
 
     /**
      * @var array
      */
-    protected static $html = [];
+    public static $html = [];
 
     /**
      * @var array
      */
-    protected static $headerJs = [];
+    public static $headerJs = [];
 
     /**
      * @var array