Ver Fonte

Merge pull request #7 from jqhph/master

拉取代码
yxx há 5 anos atrás
pai
commit
85be6d7d62

+ 3 - 0
resources/views/pages/login.blade.php

@@ -16,6 +16,9 @@
     .content {
         overflow-x: hidden;
     }
+    .form-group .control-label {
+        text-align: left;
+    }
 </style>
 
 <div class="login-page bg-40">

+ 0 - 9
src/Form/Field/Table.php

@@ -88,15 +88,6 @@ class Table extends HasMany
         return parent::value($value);
     }
 
-    protected function getKeyName()
-    {
-        if (is_null($this->form)) {
-            return;
-        }
-
-        return 'id';
-    }
-
     public function buildNestedForm($key = null)
     {
         $form = new NestedForm($this->column);

+ 1 - 1
src/Form/Row.php

@@ -109,7 +109,7 @@ class Row implements Renderable
      *
      * @return array
      */
-    public function getFields()
+    public function fields()
     {
         return $this->fields;
     }

+ 1 - 1
src/Form/Tab.php

@@ -72,7 +72,7 @@ class Tab
         foreach ($this->form->rows() as $row) {
             $rowFields = array_map(function ($field) {
                 return $field['element'];
-            }, $row->getFields());
+            }, $row->fields());
 
             $match = false;
 

+ 1 - 5
src/Show.php

@@ -685,11 +685,6 @@ class Show implements Renderable
 
             $this->fields->each->fill($model);
             $this->relations->each->model($model);
-            $this->rows->each(function ($row) {
-                $row->getFields()->each(function ($field) {
-                    $field['element']->fill($this->model());
-                });
-            });
 
             $this->callComposing();
 
@@ -714,6 +709,7 @@ class Show implements Renderable
     public function row(Closure $callback)
     {
         $this->rows->push(new Row($callback, $this));
+
         return $this;
     }
 

+ 1 - 1
src/Show/Panel.php

@@ -59,7 +59,7 @@ class Panel implements Renderable
         $this->data = [
             'fields' => new Collection(),
             'tools'  => new Tools($this),
-            'rows' => $this->parent->rows(),
+            'rows'   => $this->parent->rows(),
             'style'  => 'default',
             'title'  => trans('admin.detail'),
         ];

+ 19 - 14
src/Show/Row.php

@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
 
 class Row implements Renderable
 {
-
     /**
      * Callback for add field to current row.s.
      *
@@ -24,7 +23,7 @@ class Row implements Renderable
     protected $show;
 
     /**
-     * @var \Illuminate\Support\Collection
+     * @var Collection
      */
     protected $fields;
 
@@ -63,14 +62,13 @@ class Row implements Renderable
     }
 
     /**
-     * @return \Illuminate\Support\Collection
+     * @return Collection|\Dcat\Admin\Show\Field[]
      */
-    public function getFields()
+    public function fields()
     {
         return $this->fields;
     }
 
-
     /**
      * Set width for a incomming field.
      *
@@ -86,7 +84,9 @@ class Row implements Renderable
     }
 
     /**
-     * @param        $name
+     * Add field.
+     *
+     * @param string $name
      * @param string $label
      *
      * @return \Dcat\Admin\Show\Field
@@ -94,20 +94,25 @@ class Row implements Renderable
     public function field($name, $label = '')
     {
         $field = $this->show->field($name, $label);
+
         $this->pushField($field);
+
         return $field;
     }
 
     /**
-     * Add field
+     * Add field.
+     *
      * @param $name
      *
-     * @return \Dcat\Admin\Show\Field|\Illuminate\Support\Collection
+     * @return \Dcat\Admin\Show\Field|Collection
      */
     public function __get($name)
     {
-        $field = $this->show->__get($name);
+        $field = $this->show->field($name);
+
         $this->pushField($field);
+
         return $field;
     }
 
@@ -127,15 +132,15 @@ class Row implements Renderable
     }
 
     /**
-     * @param $field
+     * @param \Dcat\Admin\Show\Field $field
+     *
+     * @return void
      */
-    public function pushField($field)
+    protected function pushField($field)
     {
         $this->fields->push([
-            'width' => $this->defaultFieldWidth,
+            'width'   => $this->defaultFieldWidth,
             'element' => $field,
         ]);
     }
-
-
 }