Browse Source

方法重命名

jqh 5 years ago
parent
commit
27d5081519

+ 1 - 1
resources/views/form/hasmanytable.blade.php

@@ -34,7 +34,7 @@
                                 @continue
                             @endif
 
-                            <td>{!! $field->labelClass(['hidden'])->setWidth(12, 0)->render() !!}</td>
+                            <td>{!! $field->labelClass(['hidden'])->width(12, 0)->render() !!}</td>
                         @endforeach
 
                         <td class="hidden">{!! $hidden !!}</td>

+ 3 - 3
src/Form.php

@@ -314,7 +314,7 @@ class Form implements Renderable
 
         $width = $this->builder->getWidth();
 
-        $field->setWidth($width['field'], $width['label']);
+        $field->width($width['field'], $width['label']);
 
         $field::collectAssets();
 
@@ -1301,10 +1301,10 @@ class Form implements Renderable
     {
         $this->builder->fields()->each(function ($field) use ($fieldWidth, $labelWidth) {
             /* @var Field $field  */
-            $field->setWidth($fieldWidth, $labelWidth);
+            $field->width($fieldWidth, $labelWidth);
         });
 
-        $this->builder->setWidth($fieldWidth, $labelWidth);
+        $this->builder->width($fieldWidth, $labelWidth);
 
         return $this;
     }

+ 1 - 1
src/Form/Builder.php

@@ -357,7 +357,7 @@ class Builder
      *
      * @return $this
      */
-    public function setWidth($field = 8, $label = 2)
+    public function width($field = 8, $label = 2)
     {
         $this->width = [
             'label' => $label,

+ 1 - 1
src/Form/Field.php

@@ -437,7 +437,7 @@ class Field implements Renderable
      *
      * @return $this
      */
-    public function setWidth($field = 8, $label = 2)
+    public function width($field = 8, $label = 2)
     {
         $this->width = [
             'label' => $label,

+ 1 - 1
src/Form/Field/HasMany.php

@@ -680,7 +680,7 @@ JS;
             } else {
                 /* Hide label and set field width 100% */
                 $field->labelClass(['hidden']);
-                $field->setWidth(12, 0);
+                $field->width(12, 0);
                 $fields[] = $field->render();
                 $headers[] = $field->label();
             }

+ 1 - 1
src/Grid/Filter.php

@@ -306,7 +306,7 @@ class Filter implements Renderable
      */
     public function grid()
     {
-        return $this->model->getGrid();
+        return $this->model->grid();
     }
 
     /**

+ 1 - 1
src/Grid/Filter/AbstractFilter.php

@@ -187,7 +187,7 @@ abstract class AbstractFilter
      */
     protected function formatId($columns)
     {
-        return 'filter_column_'.$this->parent->getGrid()->getName().'_'.str_replace('.', '_', $columns);
+        return 'filter_column_'.$this->parent->grid()->getName().'_'.str_replace('.', '_', $columns);
     }
 
     /**

+ 2 - 2
src/Grid/Filter/Between.php

@@ -40,7 +40,7 @@ class Between extends AbstractFilter
     public function formatId($column)
     {
         $id = str_replace('.', '_', $column);
-        $prefix = 'filter_column_'.$this->parent->getGrid()->getName().'_';
+        $prefix = 'filter_column_'.$this->parent->grid()->getName().'_';
 
         return ['start' => "{$prefix}{$id}_start", 'end' => "{$prefix}{$id}_end"];
     }
@@ -54,7 +54,7 @@ class Between extends AbstractFilter
      */
     protected function formatName($column)
     {
-        $gridName = $this->parent->getGrid()->getName();
+        $gridName = $this->parent->grid()->getName();
         $prefix = $gridName ? $gridName.'_' : '';
         $columns = explode('.', $column);
 

+ 7 - 13
src/Grid/Filter/Layout/Column.php

@@ -49,23 +49,17 @@ class Column
     }
 
     /**
-     * Set column width.
+     * Get or set column width.
      *
-     * @param int $width
+     * @return int|void
      */
-    public function setWidth($width)
+    public function width($width = null)
     {
-        $this->width = $width;
-    }
+        if ($width === null) {
+            return $this->width;
+        }
 
-    /**
-     * Get column width.
-     *
-     * @return int
-     */
-    public function width()
-    {
-        return $this->width;
+        $this->width = $width;
     }
 
     /**

+ 1 - 1
src/Grid/Filter/Layout/Layout.php

@@ -57,7 +57,7 @@ class Layout
         if ($this->columns->isEmpty()) {
             $column = $this->current;
 
-            $column->setWidth($width);
+            $column->width($width);
         } else {
             $column = new Column($width);
 

+ 6 - 2
src/Show/Field.php

@@ -151,10 +151,14 @@ class Field implements Renderable
     /**
      * @param int $width
      *
-     * @return $this
+     * @return $this|int
      */
-    public function width(int $width)
+    public function width(int $width = null)
     {
+        if ($width === null) {
+            return $this->width;
+        }
+
         $this->width = $width;
 
         return $this;

+ 2 - 2
src/Widgets/Form.php

@@ -414,7 +414,7 @@ class Form implements Renderable
 
         $this->fields->each(function ($field) use ($fieldWidth, $labelWidth) {
             /* @var Field $field  */
-            $field->setWidth($fieldWidth, $labelWidth);
+            $field->width($fieldWidth, $labelWidth);
         });
 
         return $this;
@@ -450,7 +450,7 @@ class Form implements Renderable
         $this->fields->push($field);
 
         $field->setForm($this);
-        $field->setWidth($this->width['field'], $this->width['label']);
+        $field->width($this->width['field'], $this->width['label']);
 
         $field::collectAssets();