Răsfoiți Sursa

简化接口命名

jqh 6 ani în urmă
părinte
comite
267fff4ffc
100 a modificat fișierele cu 537 adăugiri și 648 ștergeri
  1. 2 2
      resources/views/form.blade.php
  2. 1 1
      resources/views/form/hasmanytable.blade.php
  3. 10 10
      resources/views/form/steps.blade.php
  4. 1 1
      resources/views/grid/selector.blade.php
  5. 5 5
      resources/views/grid/table.blade.php
  6. 5 5
      src/Admin.php
  7. 4 4
      src/Console/IdeHelperCommand.php
  8. 1 1
      src/Console/ImportCommand.php
  9. 1 1
      src/Controllers/Dashboard.php
  10. 1 1
      src/Controllers/MenuController.php
  11. 1 1
      src/Controllers/PermissionController.php
  12. 2 2
      src/Controllers/RoleController.php
  13. 3 3
      src/Controllers/UserController.php
  14. 64 83
      src/Form.php
  15. 69 87
      src/Form/Builder.php
  16. 1 1
      src/Form/Concerns/HasFieldValidator.php
  17. 4 4
      src/Form/Concerns/HasSteps.php
  18. 4 4
      src/Form/DoneStep.php
  19. 60 80
      src/Form/Field.php
  20. 1 1
      src/Form/Field/BootstrapFile.php
  21. 1 1
      src/Form/Field/BootstrapMultipleFile.php
  22. 1 1
      src/Form/Field/BootstrapUploadField.php
  23. 1 1
      src/Form/Field/Button.php
  24. 3 3
      src/Form/Field/Checkbox.php
  25. 1 1
      src/Form/Field/Color.php
  26. 1 1
      src/Form/Field/Date.php
  27. 1 1
      src/Form/Field/DateRange.php
  28. 1 1
      src/Form/Field/Display.php
  29. 1 1
      src/Form/Field/HasMany.php
  30. 2 2
      src/Form/Field/Html.php
  31. 1 1
      src/Form/Field/Icon.php
  32. 1 1
      src/Form/Field/Listbox.php
  33. 4 0
      src/Form/Field/Nullable.php
  34. 1 1
      src/Form/Field/Number.php
  35. 1 13
      src/Form/Field/Radio.php
  36. 8 8
      src/Form/Field/Select.php
  37. 5 5
      src/Form/Field/SelectResource.php
  38. 1 1
      src/Form/Field/Slider.php
  39. 3 3
      src/Form/Field/SwitchField.php
  40. 3 3
      src/Form/Field/Tags.php
  41. 5 5
      src/Form/Field/Text.php
  42. 1 1
      src/Form/Field/Tree.php
  43. 4 4
      src/Form/Field/WebUploader.php
  44. 8 8
      src/Form/StepBuilder.php
  45. 14 22
      src/Form/StepForm.php
  46. 1 1
      src/Form/Tab.php
  47. 1 1
      src/Form/Tools.php
  48. 27 45
      src/Grid.php
  49. 3 3
      src/Grid/Actions/Delete.php
  50. 1 1
      src/Grid/Actions/Edit.php
  51. 2 2
      src/Grid/Actions/QuickEdit.php
  52. 1 1
      src/Grid/Actions/Show.php
  53. 1 1
      src/Grid/Column.php
  54. 8 8
      src/Grid/Column/Filter.php
  55. 7 7
      src/Grid/Column/Filter/Between.php
  56. 3 3
      src/Grid/Column/Filter/Checkbox.php
  57. 1 1
      src/Grid/Column/Filter/Equal.php
  58. 1 1
      src/Grid/Column/Filter/Gt.php
  59. 1 1
      src/Grid/Column/Filter/In.php
  60. 3 3
      src/Grid/Column/Filter/Input.php
  61. 1 1
      src/Grid/Column/Filter/Like.php
  62. 1 1
      src/Grid/Column/Filter/Lt.php
  63. 1 1
      src/Grid/Column/Filter/Ngt.php
  64. 1 1
      src/Grid/Column/Filter/Nlt.php
  65. 1 1
      src/Grid/Column/Filter/StartWith.php
  66. 1 1
      src/Grid/Column/HasHeader.php
  67. 6 7
      src/Grid/Concerns/HasElementNames.php
  68. 8 8
      src/Grid/Concerns/HasExporter.php
  69. 7 13
      src/Grid/Concerns/HasFilter.php
  70. 1 1
      src/Grid/Concerns/HasMultipleHeader.php
  71. 1 1
      src/Grid/Concerns/HasQuickSearch.php
  72. 7 11
      src/Grid/Concerns/HasSelector.php
  73. 8 12
      src/Grid/Concerns/HasTools.php
  74. 5 5
      src/Grid/Displayers/AbstractDisplayer.php
  75. 7 7
      src/Grid/Displayers/Actions.php
  76. 2 2
      src/Grid/Displayers/Checkbox.php
  77. 1 1
      src/Grid/Displayers/DropdownActions.php
  78. 2 2
      src/Grid/Displayers/Editable.php
  79. 1 1
      src/Grid/Displayers/Expand.php
  80. 1 1
      src/Grid/Displayers/Modal.php
  81. 4 4
      src/Grid/Displayers/Orderable.php
  82. 2 2
      src/Grid/Displayers/Radio.php
  83. 7 7
      src/Grid/Displayers/RowSelector.php
  84. 2 2
      src/Grid/Displayers/Select.php
  85. 3 3
      src/Grid/Displayers/SwitchDisplay.php
  86. 2 2
      src/Grid/Displayers/SwitchGroup.php
  87. 5 5
      src/Grid/Exporter.php
  88. 3 3
      src/Grid/Exporters/AbstractExporter.php
  89. 16 16
      src/Grid/Filter.php
  90. 2 2
      src/Grid/Filter/AbstractFilter.php
  91. 1 1
      src/Grid/Filter/Presenter/MultipleSelect.php
  92. 7 7
      src/Grid/Filter/Presenter/Select.php
  93. 2 2
      src/Grid/Filter/Presenter/SelectResource.php
  94. 3 3
      src/Grid/GridAction.php
  95. 1 1
      src/Grid/Header.php
  96. 4 4
      src/Grid/Model.php
  97. 1 1
      src/Grid/Responsive.php
  98. 14 17
      src/Grid/Row.php
  99. 4 4
      src/Grid/RowAction.php
  100. 17 19
      src/Grid/Tools/BatchAction.php

+ 2 - 2
resources/views/form.blade.php

@@ -10,7 +10,7 @@
     @else
         <div class="fields-group">
             @if($form->hasRows())
-                @foreach($form->getRows() as $row)
+                @foreach($form->rows() as $row)
                     {!! $row->render() !!}
                 @endforeach
             @else
@@ -23,6 +23,6 @@
 </div>
 {!! $form->renderFooter() !!}
 
-@foreach($form->getHiddenFields() as $field)
+@foreach($form->hiddenFields() as $field)
     {!! $field->render() !!}
 @endforeach

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

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

+ 10 - 10
resources/views/form/steps.blade.php

@@ -12,27 +12,27 @@
             <ul class="la-step-horizontal la-step-label-horizontal la-step ">
                 @foreach($steps->all() as $step)
                 <li class="la-step-item">
-                    <a href="#{{ $step->getFormId() }}" class="la-step-item-container">
+                    <a href="#{{ $step->elementId() }}" class="la-step-item-container">
                         <div class="la-step-line"></div>
                         <div class="la-step-icons">
-                            <span class="la-step-icon" data-index="{{ $step->getIndex() }}">{{ $step->getIndex() + 1 }}</span>
+                            <span class="la-step-icon" data-index="{{ $step->index() }}">{{ $step->index() + 1 }}</span>
                         </div>
                         <div class="la-step-content">
-                            <div class="la-step-title">{!! $step->getTitle() !!}</div>
-                            <div class="la-step-desc"> {{ $step->getDescription() }} </div>
+                            <div class="la-step-title">{!! $step->title() !!}</div>
+                            <div class="la-step-desc"> {{ $step->description() }} </div>
                         </div>
                     </a>
                 </li>
                 @endforeach
 
                 <li class="la-step-item">
-                    <a href="#{{ $steps->getDoneStep()->getElementId() }}" class="la-step-item-container">
+                    <a href="#{{ $steps->doneStep()->elementId() }}" class="la-step-item-container">
                         <div class="la-step-line"></div>
                         <div class="la-step-icons">
                             <span class="la-step-icon" data-index="{{ $steps->count() }}"> {{ $steps->count() + 1 }} </span>
                         </div>
                         <div class="la-step-content">
-                            <div class="la-step-title">{{ $steps->getDoneStep()->title() }}</div>
+                            <div class="la-step-title">{{ $steps->doneStep()->title() }}</div>
                             <div class="la-step-desc"></div>
                         </div>
                     </a>
@@ -41,14 +41,14 @@
             <div class="la-step-form">
                 {!! $steps->build() !!}
 
-                <div id="{{ $steps->getDoneStep()->getElementId() }}" class="la-done-step" style="display: none;">
+                <div id="{{ $steps->doneStep()->elementId() }}" class="la-done-step" style="display: none;">
                 </div>
             </div>
         </div>
     @endif
 </div>
 
-@foreach($form->getHiddenFields() as $field)
+@foreach($form->hiddenFields() as $field)
     {!! $field->render() !!}
 @endforeach
 
@@ -62,7 +62,7 @@ $lastStep = $step;
 
 <script>
 LA.ready(function () {
-    var form = $('#{{ $form->getFormId() }}'),
+    var form = $('#{{ $form->elementId() }}'),
         box = form.find('.la-step-box'),
         stepInput = form.find('.current-step-input'),
         allStepInput = form.find('.all-steps-input'),
@@ -254,7 +254,7 @@ LA.ready(function () {
 
     // 按钮显示隐藏切换
     function toggle_btn() {
-        var last = {{ $lastStep->getIndex() }},
+        var last = {{ $lastStep->index() }},
             sbm = box.find('.step-submit-btn');
 
         if (smartWizard.current_index == last) {

+ 1 - 1
resources/views/grid/selector.blade.php

@@ -54,7 +54,7 @@
 </style>
 
 <div class="grid-selector">
-    @foreach($self->getSelectors() as $column => $selector)
+    @foreach($self->all() as $column => $selector)
         <div class="wrap">
             <div class="select-label">{{ $selector['label'] }}</div>
             <div class="select-options">

+ 5 - 5
resources/views/grid/table.blade.php

@@ -40,7 +40,7 @@
                 </tr>
             @endif
             <tr>
-                @foreach($grid->getColumns() as $column)
+                @foreach($grid->columns() as $column)
                     <th {!! $column->formatTitleAttributes() !!}>{!! $column->getLabel() !!}{!! $column->renderHeader() !!}</th>
                 @endforeach
             </tr>
@@ -48,9 +48,9 @@
 
             <tbody>
             @foreach($grid->rows() as $row)
-                <tr {!! $row->getRowAttributes() !!}>
-                    @foreach($grid->getColumnNames() as $name)
-                        <td {!! $row->getColumnAttributes($name) !!}>
+                <tr {!! $row->rowAttributes() !!}>
+                    @foreach($grid->columnNames() as $name)
+                        <td {!! $row->columnAttributes($name) !!}>
                             {!! $row->column($name) !!}
                         </td>
                     @endforeach
@@ -58,7 +58,7 @@
             @endforeach
             @if ($grid->rows()->isEmpty())
                 <tr>
-                    <td colspan="{!! count($grid->getColumnNames()) !!}">
+                    <td colspan="{!! count($grid->columnNames()) !!}">
                         <div style="margin:5px 0 0 10px;"><span class="help-block" style="margin-bottom:0"><i class="fa fa-info-circle"></i>&nbsp;{{ trans('admin.no_data') }}</span></div>
                     </td>
                 </tr>

+ 5 - 5
src/Admin.php

@@ -188,7 +188,7 @@ class Admin
                     $show = new Show($id);
                 } else {
                     $show = new Show();
-                    $show->setKey($id);
+                    $show->key($id);
                 }
 
                 break;
@@ -198,17 +198,17 @@ class Admin
                 } elseif ($repository instanceof \Closure) {
                     $show = new Show(null, $repository);
 
-                    $show->setKey($id);
+                    $show->key($id);
                 } elseif ($repository instanceof Repository) {
                     $show = new Show($repository);
 
-                    $show->setKey($id);
+                    $show->key($id);
                 }
                 break;
             case 3:
                 $show = new Show($repository, $callable);
 
-                $show->setKey($id);
+                $show->key($id);
         }
 
         return $show;
@@ -371,7 +371,7 @@ class Admin
      *
      * @return array
      */
-    public static function getExtensions()
+    public static function extensions()
     {
         return static::$extensions;
     }

+ 4 - 4
src/Console/IdeHelperCommand.php

@@ -224,7 +224,7 @@ class IdeHelperCommand extends Command
 
         $reject = $fields[1];
 
-        $fields = collect(Grid\Filter::getExtensions())->reject(function ($value, $key) use (&$reject) {
+        $fields = collect(Grid\Filter::extensions())->reject(function ($value, $key) use (&$reject) {
             return in_array($key, $reject);
         });
 
@@ -244,7 +244,7 @@ class IdeHelperCommand extends Command
      */
     protected function generateShowFields()
     {
-        $extensions = collect(Show\Field::getExtensions());
+        $extensions = collect(Show\Field::extensions());
 
         $space = str_repeat(' ', 5);
 
@@ -268,7 +268,7 @@ class IdeHelperCommand extends Command
 
         $reject = $fields[1];
 
-        $fields = collect(Form::getExtensions())->reject(function ($value, $key) use (&$reject) {
+        $fields = collect(Form::extensions())->reject(function ($value, $key) use (&$reject) {
             return in_array($key, $reject);
         });
 
@@ -294,7 +294,7 @@ class IdeHelperCommand extends Command
 
         $reject = $column[1];
 
-        $columns = collect(array_keys(Grid\Column::getExtensions()))->reject(function ($displayer) use (&$reject) {
+        $columns = collect(array_keys(Grid\Column::extensions()))->reject(function ($displayer) use (&$reject) {
             return in_array($displayer, $reject);
         });
 

+ 1 - 1
src/Console/ImportCommand.php

@@ -33,7 +33,7 @@ class ImportCommand extends VendorPublishCommand
     {
         $extension = $this->argument('extension');
 
-        $extensions = Admin::getExtensions();
+        $extensions = Admin::extensions();
 
         if (empty($extension) || ! Arr::has($extensions, $extension)) {
             $extension = $this->choice('Please choose a extension to import', array_keys($extensions));

+ 1 - 1
src/Controllers/Dashboard.php

@@ -79,7 +79,7 @@ class Dashboard
         ];
 
         foreach ($extensions as &$extension) {
-            $extension['installed'] = array_key_exists($extension['key'], Admin::getExtensions());
+            $extension['installed'] = array_key_exists($extension['key'], Admin::extensions());
         }
 
         return view('admin::dashboard.extensions', compact('extensions'));

+ 1 - 1
src/Controllers/MenuController.php

@@ -49,7 +49,7 @@ class MenuController extends Controller
                     }
                     $form->hidden('_token')->default(csrf_token());
 
-                    $form->setWidth(9, 2);
+                    $form->width(9, 2);
 
                     $column->append(Card::make(trans('admin.new'), $form)->class('card material'));
                 });

+ 1 - 1
src/Controllers/PermissionController.php

@@ -291,7 +291,7 @@ class PermissionController extends Controller
             $permissionTable = config('admin.database.permissions_table');
             $connection = config('admin.database.connection');
 
-            $id = $form->getKey();
+            $id = $form->key();
 
             $form->display('id', 'ID');
 

+ 2 - 2
src/Controllers/RoleController.php

@@ -145,7 +145,7 @@ class RoleController extends Controller
             $show->created_at;
             $show->updated_at;
 
-            if ($show->getKey() == RoleModel::ADMINISTRATOR_ID) {
+            if ($show->key() == RoleModel::ADMINISTRATOR_ID) {
                 $show->disableDeleteButton();
             }
         });
@@ -162,7 +162,7 @@ class RoleController extends Controller
             $roleTable = config('admin.database.roles_table');
             $connection = config('admin.database.connection');
 
-            $id = $form->getKey();
+            $id = $form->key();
 
             $form->display('id', 'ID');
 

+ 3 - 3
src/Controllers/UserController.php

@@ -125,7 +125,7 @@ class UserController extends Controller
             $grid->quickSearch(['id', 'name', 'username']);
 
             $grid->actions(function (Grid\Displayers\Actions $actions) {
-                if ($actions->getKey() == AdministratorModel::DEFAULT_ID) {
+                if ($actions->key() == AdministratorModel::DEFAULT_ID) {
                     $actions->disableDelete();
                 }
             });
@@ -211,7 +211,7 @@ class UserController extends Controller
                 return $tree->render();
             });
 
-            if ($show->getKey() == AdministratorModel::DEFAULT_ID) {
+            if ($show->key() == AdministratorModel::DEFAULT_ID) {
                 $show->disableDeleteButton();
             }
         });
@@ -229,7 +229,7 @@ class UserController extends Controller
 
             $connection = config('admin.database.connection');
 
-            $id = $form->getKey();
+            $id = $form->key();
 
             $form->display('id', 'ID');
 

+ 64 - 83
src/Form.php

@@ -283,7 +283,7 @@ class Form implements Renderable
         $this->builder = new Builder($this);
         $this->isSoftDeletes = $repository ? $this->repository->isSoftDeletes() : false;
 
-        $this->setModel(new Fluent());
+        $this->model(new Fluent());
         $this->prepareModalForm();
         $this->callResolving();
     }
@@ -368,19 +368,17 @@ class Form implements Renderable
         return $this->builder->isDeleting();
     }
 
-    /**
-     * @return Fluent
-     */
-    public function model()
-    {
-        return $this->model;
-    }
-
     /**
      * @param Fluent $model
+     *
+     * @return Fluent|void
      */
-    public function setModel(Fluent $model)
+    public function model(Fluent $model = null)
     {
+        if ($model === null) {
+            return $this->model;
+        }
+
         $this->model = $model;
     }
 
@@ -389,9 +387,9 @@ class Form implements Renderable
      *
      * @return mixed
      */
-    public function getKey()
+    public function key()
     {
-        return $this->builder()->getResourceId();
+        return $this->builder()->resourceId();
     }
 
     /**
@@ -439,9 +437,9 @@ class Form implements Renderable
     /**
      * @return string
      */
-    public function getFormId()
+    public function elementId()
     {
-        return $this->builder->getFormId();
+        return $this->builder->elementId();
     }
 
     /**
@@ -461,8 +459,8 @@ class Form implements Renderable
      */
     public function edit($id)
     {
-        $this->builder->setMode(Builder::MODE_EDIT);
-        $this->builder->setResourceId($id);
+        $this->builder->mode(Builder::MODE_EDIT);
+        $this->builder->resourceId($id);
 
         $this->setFieldValue();
 
@@ -529,12 +527,12 @@ class Form implements Renderable
     public function destroy($id)
     {
         try {
-            $this->builder->setResourceId($id);
-            $this->builder->setMode(Builder::MODE_DELETE);
+            $this->builder->resourceId($id);
+            $this->builder->mode(Builder::MODE_DELETE);
 
             $data = $this->repository->getDataWhenDeleting($this);
 
-            $this->setModel(new Fluent($data));
+            $this->model(new Fluent($data));
 
             $this->build();
 
@@ -584,7 +582,7 @@ class Form implements Renderable
 
         $id = $this->repository->store($this);
 
-        $this->builder->setResourceId($id);
+        $this->builder->resourceId($id);
 
         if (($response = $this->callSaved())) {
             return $response;
@@ -595,7 +593,7 @@ class Form implements Renderable
         }
 
         return $this->redirect(
-            $this->getRedirectUrl($id, $redirectTo),
+            $this->redirectUrl($id, $redirectTo),
             trans('admin.save_succeeded')
         );
     }
@@ -690,24 +688,18 @@ class Form implements Renderable
     }
 
     /**
-     * Get data for insert or update.
-     *
-     * @return array
-     */
-    public function getUpdates(): array
-    {
-        return $this->updates;
-    }
-
-    /**
-     * Set data for insert or update.
+     * Get or Set data for insert or update.
      *
      * @param array $updates
      *
-     * @return $this
+     * @return $this|array
      */
-    public function setUpdates(array $updates)
+    public function updates(array $updates = null)
     {
+        if ($updates === null) {
+            return $this->updates;
+        }
+
         $this->updates = array_merge($this->updates, $updates);
 
         return $this;
@@ -759,7 +751,7 @@ class Form implements Renderable
         }
 
         return $this->redirect(
-            $this->getRedirectUrl($id, $redirectTo),
+            $this->redirectUrl($id, $redirectTo),
             trans('admin.update_succeeded')
         );
     }
@@ -773,8 +765,8 @@ class Form implements Renderable
      */
     protected function beforeUpdate($id, array &$data)
     {
-        $this->builder->setResourceId($id);
-        $this->builder->setMode(Builder::MODE_EDIT);
+        $this->builder->resourceId($id);
+        $this->builder->mode(Builder::MODE_EDIT);
 
         $this->build();
 
@@ -792,7 +784,7 @@ class Form implements Renderable
 
         $data = $this->handleFileDelete($data);
 
-        $this->setModel(new Fluent($this->repository->getDataWhenUpdating($this)));
+        $this->model(new Fluent($this->repository->getDataWhenUpdating($this)));
         $this->setFieldOriginalValue();
 
         if ($response = $this->handleOrderable($data)) {
@@ -817,7 +809,7 @@ class Form implements Renderable
      *
      * @return string|false
      */
-    public function getRedirectUrl($key, $redirectTo = null)
+    public function redirectUrl($key, $redirectTo = null)
     {
         if ($redirectTo) {
             return $redirectTo;
@@ -1022,7 +1014,7 @@ class Form implements Renderable
      *
      * @return string
      */
-    public function getKeyName()
+    public function keyName()
     {
         if (! $this->repository) {
             return 'id';
@@ -1034,7 +1026,7 @@ class Form implements Renderable
     /**
      * @return string|void
      */
-    public function getCreatedAtColumn()
+    public function createdAtColumn()
     {
         if (! $this->repository) {
             return;
@@ -1046,7 +1038,7 @@ class Form implements Renderable
     /**
      * @return string|void
      */
-    public function getUpdatedAtColumn()
+    public function updatedAtColumn()
     {
         if (! $this->repository) {
             return;
@@ -1055,14 +1047,6 @@ class Form implements Renderable
         return $this->repository->getUpdatedAtColumn();
     }
 
-    /**
-     * @return Repository
-     */
-    public function getRepository(): Repository
-    {
-        return $this->repository;
-    }
-
     /**
      * @param array        $data
      * @param string|array $columns
@@ -1175,7 +1159,7 @@ class Form implements Renderable
     protected function rendering()
     {
         if ($isEditing = $this->isEditing()) {
-            $this->setModel(new Fluent($this->repository->edit($this)));
+            $this->model(new Fluent($this->repository->edit($this)));
         }
 
         $this->build();
@@ -1287,25 +1271,22 @@ class Form implements Renderable
     }
 
     /**
-     * Set action for form.
+     * Get or set action for form.
      *
-     * @param string $action
+     * @param string|null $action
      *
-     * @return $this
+     * @return $this|string
      */
-    public function setAction($action)
+    public function action($action = null)
     {
-        $this->builder->setAction($action);
+        $value = $this->builder->action($action);
 
-        return $this;
-    }
+        if ($action === null) {
+            return $value;
+        }
 
-    /**
-     * @return string
-     */
-    public function getAction()
-    {
-        return $this->builder->getAction();
+
+        return $this;
     }
 
     /**
@@ -1316,7 +1297,7 @@ class Form implements Renderable
      *
      * @return $this
      */
-    public function setWidth($fieldWidth = 8, $labelWidth = 2)
+    public function width($fieldWidth = 8, $labelWidth = 2)
     {
         $this->builder->fields()->each(function ($field) use ($fieldWidth, $labelWidth) {
             /* @var Field $field  */
@@ -1335,23 +1316,23 @@ class Form implements Renderable
      *
      * @return $this
      */
-    public function setView($view)
+    public function view($view)
     {
-        $this->builder->setView($view);
+        $this->builder->view($view);
 
         return $this;
     }
 
     /**
-     * Set title for form.
+     * Get or set title for form.
      *
      * @param string $title
      *
      * @return $this
      */
-    public function setTitle($title = '')
+    public function title($title = null)
     {
-        $this->builder->setTitle($title);
+        $this->builder->title($title);
 
         return $this;
     }
@@ -1373,7 +1354,7 @@ class Form implements Renderable
     /**
      * @return Row[]
      */
-    public function getRows()
+    public function rows()
     {
         return $this->rows;
     }
@@ -1387,7 +1368,7 @@ class Form implements Renderable
      */
     public function tools(Closure $callback)
     {
-        $callback->call($this, $this->builder->getTools());
+        $callback->call($this, $this->builder->tools());
 
         return $this;
     }
@@ -1423,7 +1404,7 @@ class Form implements Renderable
      */
     public function disableSubmitButton(bool $disable = true)
     {
-        $this->builder->getFooter()->disableSubmit($disable);
+        $this->builder->footer()->disableSubmit($disable);
 
         return $this;
     }
@@ -1435,7 +1416,7 @@ class Form implements Renderable
      */
     public function disableResetButton(bool $disable = true)
     {
-        $this->builder->getFooter()->disableReset($disable);
+        $this->builder->footer()->disableReset($disable);
 
         return $this;
     }
@@ -1447,7 +1428,7 @@ class Form implements Renderable
      */
     public function disableViewCheck(bool $disable = true)
     {
-        $this->builder->getFooter()->disableViewCheck($disable);
+        $this->builder->footer()->disableViewCheck($disable);
 
         return $this;
     }
@@ -1459,7 +1440,7 @@ class Form implements Renderable
      */
     public function disableEditingCheck(bool $disable = true)
     {
-        $this->builder->getFooter()->disableEditingCheck($disable);
+        $this->builder->footer()->disableEditingCheck($disable);
 
         return $this;
     }
@@ -1471,7 +1452,7 @@ class Form implements Renderable
      */
     public function disableCreatingCheck(bool $disable = true)
     {
-        $this->builder->getFooter()->disableCreatingCheck($disable);
+        $this->builder->footer()->disableCreatingCheck($disable);
 
         return $this;
     }
@@ -1483,7 +1464,7 @@ class Form implements Renderable
      */
     public function disableViewButton(bool $disable = true)
     {
-        $this->builder->getTools()->disableView($disable);
+        $this->builder->tools()->disableView($disable);
 
         return $this;
     }
@@ -1495,7 +1476,7 @@ class Form implements Renderable
      */
     public function disableListButton(bool $disable = true)
     {
-        $this->builder->getTools()->disableList($disable);
+        $this->builder->tools()->disableList($disable);
 
         return $this;
     }
@@ -1507,7 +1488,7 @@ class Form implements Renderable
      */
     public function disableDeleteButton(bool $disable = true)
     {
-        $this->builder->getTools()->disableDelete($disable);
+        $this->builder->tools()->disableDelete($disable);
 
         return $this;
     }
@@ -1521,7 +1502,7 @@ class Form implements Renderable
      */
     public function footer(Closure $callback)
     {
-        call_user_func($callback, $this->builder->getFooter());
+        call_user_func($callback, $this->builder->footer());
 
         return $this;
     }
@@ -1543,7 +1524,7 @@ class Form implements Renderable
             $segments = array_slice($segments, 0, $slice);
         }
 
-        return \url(implode('/', $segments));
+        return url(implode('/', $segments));
     }
 
     /**
@@ -1684,7 +1665,7 @@ class Form implements Renderable
     /**
      * @return array
      */
-    public static function getExtensions()
+    public static function extensions()
     {
         return static::$availableFields;
     }

+ 69 - 87
src/Form/Builder.php

@@ -118,7 +118,7 @@ class Builder
     /**
      * @var string
      */
-    protected $formId;
+    protected $elementId;
 
     /**
      * @var \Closure
@@ -219,7 +219,7 @@ class Builder
      *
      * @return Tools
      */
-    public function getTools()
+    public function tools()
     {
         return $this->tools;
     }
@@ -229,7 +229,7 @@ class Builder
      *
      * @return Footer
      */
-    public function getFooter()
+    public function footer()
     {
         return $this->footer;
     }
@@ -257,7 +257,7 @@ class Builder
     /**
      * @return StepBuilder
      */
-    public function getStepBuilder()
+    public function stepBuilder()
     {
         return $this->stepBuilder;
     }
@@ -267,19 +267,15 @@ class Builder
      *
      * @param string $mode
      *
-     * @return void
+     * @return void|string
      */
-    public function setMode(string $mode = self::MODE_CREATE)
+    public function mode(string $mode = null)
     {
-        $this->mode = $mode;
-    }
+        if ($mode === null) {
+            return $this->mode;
+        }
 
-    /**
-     * @return string
-     */
-    public function getMode()
-    {
-        return $this->mode;
+        $this->mode = $mode;
     }
 
     /**
@@ -329,21 +325,15 @@ class Builder
      *
      * @param $id
      *
-     * @return void
+     * @return mixed|void
      */
-    public function setResourceId($id)
+    public function resourceId($id = null)
     {
-        $this->id = $id;
-    }
+        if ($id === null) {
+            return $this->id;
+        }
 
-    /**
-     * Get Resource id.
-     *
-     * @return mixed
-     */
-    public function getResourceId()
-    {
-        return $this->id;
+        $this->id = $id;
     }
 
     /**
@@ -388,22 +378,18 @@ class Builder
     }
 
     /**
-     * Set form action.
+     * Get or set action for form.
      *
-     * @param string $action
+     * @return string|void
      */
-    public function setAction($action)
+    public function action($action = null)
     {
-        $this->action = $action;
-    }
+        if ($action !== null) {
+            $this->action = $action;
+
+            return;
+        }
 
-    /**
-     * Get Form action.
-     *
-     * @return string
-     */
-    public function getAction()
-    {
         if ($this->action) {
             return $this->action;
         }
@@ -426,7 +412,7 @@ class Builder
      *
      * @return $this
      */
-    public function setView($view)
+    public function view($view)
     {
         $this->view = $view;
 
@@ -434,17 +420,33 @@ class Builder
     }
 
     /**
-     * Set title for form.
+     * Get or set title for form.
      *
      * @param string $title
      *
-     * @return $this
+     * @return $this|string
      */
-    public function setTitle($title)
+    public function title($title = null)
     {
-        $this->title = $title;
+        if ($title !== null) {
+            $this->title = $title;
 
-        return $this;
+            return $this;
+        }
+
+        if ($this->title) {
+            return $this->title;
+        }
+
+        if ($this->mode == static::MODE_CREATE) {
+            return trans('admin.create');
+        }
+
+        if ($this->mode == static::MODE_EDIT) {
+            return trans('admin.edit');
+        }
+
+        return '';
     }
 
     /**
@@ -478,7 +480,7 @@ class Builder
      */
     public function stepField($name)
     {
-        if (! $builder = $this->getStepBuilder()) {
+        if (! $builder = $this->stepBuilder()) {
             return;
         }
 
@@ -496,7 +498,7 @@ class Builder
     {
         $fields = new Collection();
 
-        if (! $builder = $this->getStepBuilder()) {
+        if (! $builder = $this->stepBuilder()) {
             return $fields;
         }
 
@@ -526,7 +528,7 @@ class Builder
      */
     public function hasRows()
     {
-        return ! empty($this->form->getRows());
+        return ! empty($this->form->rows());
     }
 
     /**
@@ -534,15 +536,15 @@ class Builder
      *
      * @return array
      */
-    public function getRows()
+    public function rows()
     {
-        return $this->form->getRows();
+        return $this->form->rows();
     }
 
     /**
      * @return array
      */
-    public function getHiddenFields()
+    public function hiddenFields()
     {
         return $this->hiddenFields;
     }
@@ -615,37 +617,17 @@ class Builder
      *
      * @return void
      */
-    public function setFormId($id)
+    public function setElementId($id)
     {
-        $this->formId = $id;
+        $this->elementId = $id;
     }
 
     /**
      * @return string
      */
-    public function getFormId()
+    public function elementId()
     {
-        return $this->formId ?: ($this->formId = 'form-'.Str::random(8));
-    }
-
-    /**
-     * @return string
-     */
-    public function title()
-    {
-        if ($this->title) {
-            return $this->title;
-        }
-
-        if ($this->mode == static::MODE_CREATE) {
-            return trans('admin.create');
-        }
-
-        if ($this->mode == static::MODE_EDIT) {
-            return trans('admin.edit');
-        }
-
-        return '';
+        return $this->elementId ?: ($this->elementId = 'form-'.Str::random(8));
     }
 
     /**
@@ -702,8 +684,8 @@ class Builder
 
         $this->addRedirectUrlField();
 
-        $attributes['id'] = $this->getFormId();
-        $attributes['action'] = $this->getAction();
+        $attributes['id'] = $this->elementId();
+        $attributes['action'] = $this->action();
         $attributes['method'] = Arr::get($options, 'method', 'post');
         $attributes['accept-charset'] = 'UTF-8';
         $attributes['data-toggle'] = 'validator';
@@ -746,9 +728,9 @@ class Builder
         }
 
         $reservedColumns = [
-            $this->form->getKeyName(),
-            $this->form->getCreatedAtColumn(),
-            $this->form->getUpdatedAtColumn(),
+            $this->form->keyName(),
+            $this->form->createdAtColumn(),
+            $this->form->updatedAtColumn(),
         ];
 
         $this->fields = $this->fields()->reject(function (Field $field) use (&$reservedColumns) {
@@ -806,7 +788,7 @@ class Builder
             'form'       => $this,
             'tabObj'     => $tabObj,
             'width'      => $this->width,
-            'formId'     => $this->getFormId(),
+            'elementId'  => $this->elementId(),
             'showHeader' => $this->showHeader,
             'steps'      => $this->stepBuilder,
         ];
@@ -843,7 +825,7 @@ EOF;
         Admin::script(
             <<<JS
 (function () {
-    var f = $('#{$this->getFormId()}');
+    var f = $('#{$this->elementId()}');
 
     f.find('[type="submit"]').click(function () {
         var t = $(this);
@@ -875,27 +857,27 @@ JS
      */
     protected function setupTabScript()
     {
-        $formId = $this->getFormId();
+        $elementId = $this->elementId();
 
         $script = <<<JS
 (function () {
     var hash = document.location.hash;
     if (hash) {
-        $('#$formId .nav-tabs a[href="' + hash + '"]').tab('show');
+        $('#$elementId .nav-tabs a[href="' + hash + '"]').tab('show');
     }
     
     // Change hash for page-reload
-    $('#$formId .nav-tabs a').on('shown.bs.tab', function (e) {
+    $('#$elementId .nav-tabs a').on('shown.bs.tab', function (e) {
         history.pushState(null,null, e.target.hash);
     });
     
-    if ($('#$formId .has-error').length) {
-        $('#$formId .has-error').each(function () {
+    if ($('#$elementId .has-error').length) {
+        $('#$elementId .has-error').each(function () {
             var tabId = '#'+$(this).closest('.tab-pane').attr('id');
             $('li a[href="'+tabId+'"] i').removeClass('hide');
         });
     
-        var first = $('#$formId .has-error:first').closest('.tab-pane').attr('id');
+        var first = $('#$elementId .has-error:first').closest('.tab-pane').attr('id');
         $('li a[href="#'+first+'"]').tab('show');
     }
 })();

+ 1 - 1
src/Form/Concerns/HasFieldValidator.php

@@ -133,7 +133,7 @@ trait HasFieldValidator
             return $rules;
         }
 
-        if (method_exists($this->form, 'getKey') || ! $id = $this->form->getKey()) {
+        if (method_exists($this->form, 'key') || ! $id = $this->form->key()) {
             return $rules;
         }
 

+ 4 - 4
src/Form/Concerns/HasSteps.php

@@ -28,7 +28,7 @@ trait HasSteps
      */
     protected function prepareStepFormFields(array $data)
     {
-        $stepBuilder = $this->builder->getStepBuilder();
+        $stepBuilder = $this->builder->stepBuilder();
 
         if (
             empty($stepBuilder)
@@ -84,7 +84,7 @@ trait HasSteps
     {
         // Handle validation errors.
         if ($validationMessages = $this->validationMessages($data)) {
-            return $this->makeValidationErrorsResponse($validationMessages);
+            return $this->validationErrorsResponse($validationMessages);
         }
 
         // Stash input data.
@@ -98,12 +98,12 @@ trait HasSteps
      */
     protected function responseDoneStep()
     {
-        if (! $builder = $this->builder->getStepBuilder()) {
+        if (! $builder = $this->builder->stepBuilder()) {
             return;
         }
 
         return response(
-            $builder->getDoneStep()
+            $builder->doneStep()
                 ->finish()
                 ->render()
         );

+ 4 - 4
src/Form/DoneStep.php

@@ -83,7 +83,7 @@ class DoneStep
     /**
      * @return string
      */
-    public function getElementId(): string
+    public function elementId(): string
     {
         return $this->elementId;
     }
@@ -91,9 +91,9 @@ class DoneStep
     /**
      * @return array
      */
-    public function getNewId()
+    public function newId()
     {
-        return $this->form->getKey();
+        return $this->form->key();
     }
 
     /**
@@ -104,7 +104,7 @@ class DoneStep
      */
     public function input($key = null, $default = null)
     {
-        $input = $this->form->getUpdates();
+        $input = $this->form->updates();
 
         if ($key === null) {
             return $input;

+ 60 - 80
src/Form/Field.php

@@ -225,7 +225,7 @@ class Field implements Renderable
      *
      * @return string|array
      */
-    public function getElementId()
+    public function elementId()
     {
         return $this->id;
     }
@@ -420,7 +420,7 @@ class Field implements Renderable
     /**
      * @return Fluent
      */
-    public function getFormModel()
+    public function values()
     {
         return $this->form ? $this->form->model() : new Fluent();
     }
@@ -484,7 +484,7 @@ class Field implements Renderable
      *
      * @return string
      */
-    public function getErrorKey()
+    public function errorKey()
     {
         return $this->errorKey ?: $this->column;
     }
@@ -513,7 +513,7 @@ class Field implements Renderable
     public function value($value = null)
     {
         if (is_null($value)) {
-            return is_null($this->value) ? $this->getDefault() : $this->value;
+            return is_null($this->value) ? $this->default() : $this->value;
         }
 
         $this->value = $value;
@@ -540,31 +540,25 @@ class Field implements Renderable
     }
 
     /**
-     * Set default value for field.
+     * Get or set default value for field.
      *
      * @param $default
      *
      * @return $this
      */
-    public function default($default)
+    public function default($default = null)
     {
-        $this->default = $default;
-
-        return $this;
-    }
+        if ($default === null) {
+            if ($this->default instanceof \Closure) {
+                return call_user_func($this->default, $this->form);
+            }
 
-    /**
-     * Get default value.
-     *
-     * @return mixed
-     */
-    public function getDefault()
-    {
-        if ($this->default instanceof \Closure) {
-            return call_user_func($this->default, $this->form);
+            return $this->default;
         }
 
-        return $this->default;
+        $this->default = $default;
+
+        return $this;
     }
 
     /**
@@ -693,7 +687,7 @@ class Field implements Renderable
     public function required($isLabelAsterisked = true)
     {
         if ($isLabelAsterisked) {
-            $this->setLabelClass(['asterisk']);
+            $this->labelClass(['asterisk']);
         }
 
         $this->rules('required');
@@ -732,29 +726,23 @@ class Field implements Renderable
     }
 
     /**
-     * Set field placeholder.
+     * Get or set field placeholder.
      *
      * @param string $placeholder
      *
-     * @return $this
+     * @return $this|string
      */
-    public function placeholder($placeholder = '')
+    public function placeholder($placeholder = null)
     {
+        if ($placeholder === null) {
+            return $this->placeholder ?: trans('admin.input').' '.$this->label;
+        }
+
         $this->placeholder = $placeholder;
 
         return $this;
     }
 
-    /**
-     * Get placeholder.
-     *
-     * @return string
-     */
-    public function getPlaceholder()
-    {
-        return $this->placeholder ?: trans('admin.input').' '.$this->label;
-    }
-
     /**
      * Prepare for a field value before update or insert.
      *
@@ -828,17 +816,17 @@ class Field implements Renderable
     /**
      * @return array
      */
-    public function getViewElementClasses()
+    public function viewElementClasses()
     {
         if ($this->horizontal) {
             return [
-                'label'      => "col-sm-{$this->width['label']} {$this->getLabelClass()}",
+                'label'      => "col-sm-{$this->width['label']} {$this->labelClass()}",
                 'field'      => "col-sm-{$this->width['field']}",
                 'form-group' => 'form-group ',
             ];
         }
 
-        return ['label' => $this->getLabelClass(), 'field' => '', 'form-group' => ''];
+        return ['label' => $this->labelClass(), 'field' => '', 'form-group' => ''];
     }
 
     /**
@@ -846,29 +834,23 @@ class Field implements Renderable
      *
      * @param string|array $class
      *
-     * @return $this
+     * @return $this|array
      */
-    public function setElementClass($class)
+    public function elementClass($class = null)
     {
-        $this->elementClass = array_merge($this->elementClass, (array) $class);
-
-        return $this;
-    }
+        if ($class === null) {
+            if (! $this->elementClass) {
+                $name = $this->elementName ?: $this->formatName($this->column);
 
-    /**
-     * Get element class.
-     *
-     * @return array
-     */
-    protected function getElementClass()
-    {
-        if (! $this->elementClass) {
-            $name = $this->elementName ?: $this->formatName($this->column);
+                $this->elementClass = (array) str_replace(['[', ']'], '_', $name);
+            }
 
-            $this->elementClass = (array) str_replace(['[', ']'], '_', $name);
+            return $this->elementClass;
         }
 
-        return $this->elementClass;
+        $this->elementClass = array_merge($this->elementClass, (array) $class);
+
+        return $this;
     }
 
     /**
@@ -876,9 +858,9 @@ class Field implements Renderable
      *
      * @return mixed
      */
-    protected function getElementClassString()
+    protected function elementClassString()
     {
-        $elementClass = $this->getElementClass();
+        $elementClass = $this->elementClass();
 
         if (Arr::isAssoc($elementClass)) {
             $classes = [];
@@ -898,11 +880,11 @@ class Field implements Renderable
      *
      * @return string|array
      */
-    protected function getElementClassSelector()
+    protected function elementClassSelector()
     {
-        $elementClass = $this->getElementClass();
+        $elementClass = $this->elementClass();
 
-        $formId = $this->getFormId();
+        $formId = $this->formElementId();
         $formId = $formId ? '#'.$formId : '';
 
         if (Arr::isAssoc($elementClass)) {
@@ -938,9 +920,9 @@ class Field implements Renderable
     /**
      * @return string|null
      */
-    protected function getFormId()
+    protected function formElementId()
     {
-        return $this->form ? $this->form->getFormId() : null;
+        return $this->form ? $this->form->elementId() : null;
     }
 
     /**
@@ -997,22 +979,18 @@ class Field implements Renderable
         return $this;
     }
 
-    /**
-     * @return string
-     */
-    public function getLabelClass(): string
-    {
-        return implode(' ', $this->labelClass);
-    }
-
     /**
      * @param array|string $labelClass
      * @param bool         $append
      *
-     * @return $this
+     * @return $this|string
      */
-    public function setLabelClass($labelClass, bool $append = true)
+    public function labelClass($labelClass = null, bool $append = true)
     {
+        if ($labelClass === null) {
+            return implode(' ', $this->labelClass);
+        }
+
         $this->labelClass = $append
             ? array_unique(array_merge($this->labelClass, (array) $labelClass))
             : (array) $labelClass;
@@ -1023,7 +1001,7 @@ class Field implements Renderable
     /**
      * @return string
      */
-    public function getElementName()
+    public function elementName()
     {
         return $this->elementName ?: $this->formatName($this->column);
     }
@@ -1037,18 +1015,18 @@ class Field implements Renderable
     {
         return array_merge($this->variables, [
             'id'          => $this->id,
-            'name'        => $this->getElementName(),
+            'name'        => $this->elementName(),
             'help'        => $this->help,
-            'class'       => $this->getElementClassString(),
+            'class'       => $this->elementClassString(),
             'value'       => $this->value(),
             'label'       => $this->label,
-            'viewClass'   => $this->getViewElementClasses(),
+            'viewClass'   => $this->viewElementClasses(),
             'column'      => $this->column,
-            'errorKey'    => $this->getErrorKey(),
+            'errorKey'    => $this->errorKey(),
             'attributes'  => $this->formatAttributes(),
-            'placeholder' => $this->getPlaceholder(),
+            'placeholder' => $this->placeholder(),
             'disabled'    => $this->attributes['disabled'] ?? false,
-            'formId'      => $this->getFormId(),
+            'formId'      => $this->formElementId(),
         ]);
     }
 
@@ -1067,7 +1045,7 @@ class Field implements Renderable
      *
      * @return string
      */
-    public function setView($view)
+    public function view($view)
     {
         $this->view = $view;
 
@@ -1148,6 +1126,8 @@ class Field implements Renderable
      */
     public function __toString()
     {
-        return $this->render()->render();
+        $view = $this->render();
+
+        return $view instanceof Renderable ? $view->render() : (string) $view;
     }
 }

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

@@ -187,7 +187,7 @@ class BootstrapFile extends Field
         $options = json_encode($this->options);
 
         $this->script = <<<JS
-$("{$this->getElementClassSelector()}").fileinput({$options});
+$("{$this->elementClassSelector()}").fileinput({$options});
 JS;
 
         return parent::render();

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

@@ -227,7 +227,7 @@ class BootstrapMultipleFile extends Field
         $options = json_encode($this->options);
 
         $this->script = <<<JS
-$("{$this->getElementClassSelector()}").fileinput({$options});
+$("{$this->elementClassSelector()}").fileinput({$options});
 JS;
 
         return parent::render();

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

@@ -90,7 +90,7 @@ trait BootstrapUploadField
         ];
 
         if ($this->form instanceof Form) {
-            $defaultOptions['deleteUrl'] = $this->form->getResource().'/'.$this->form->builder()->getResourceId();
+            $defaultOptions['deleteUrl'] = $this->form->getResource().'/'.$this->form->key();
         }
 
         $this->options($defaultOptions);

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

@@ -18,7 +18,7 @@ class Button extends Field
     public function on($event, $callback)
     {
         $this->script = <<<JS
-        $('{$this->getElementClassSelector()}').on('$event', function() {
+        $('{$this->elementClassSelector()}').on('$event', function() {
             $callback
         });
 JS;

+ 3 - 3
src/Form/Field/Checkbox.php

@@ -98,11 +98,11 @@ class Checkbox extends MultipleSelect
     {
         if (is_null($value)) {
             if ($this->value === null) {
-                return $this->getDefault();
+                return $this->default();
             }
 
             if (count($this->value) === 0) {
-                return $this->getDefault();
+                return $this->default();
             }
 
             return $this->value;
@@ -120,7 +120,7 @@ class Checkbox extends MultipleSelect
     {
         if ($this->options instanceof \Closure) {
             $this->options(
-                $this->options->call($this->getFormModel(), $this->value(), $this)
+                $this->options->call($this->values(), $this->value(), $this)
             );
         }
 

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

@@ -51,7 +51,7 @@ class Color extends Text
     {
         $options = json_encode($this->options);
 
-        $this->script = "$('{$this->getElementClassSelector()}').parent().colorpicker($options);";
+        $this->script = "$('{$this->elementClassSelector()}').parent().colorpicker($options);";
 
         $this->prepend('<i></i>')
             ->defaultAttribute('style', 'width: 200px');

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

@@ -30,7 +30,7 @@ class Date extends Text
         $this->options['locale'] = config('app.locale');
         $this->options['allowInputToggle'] = true;
 
-        $this->script = "$('{$this->getElementClassSelector()}').parent().datetimepicker(".json_encode($this->options).');';
+        $this->script = "$('{$this->elementClassSelector()}').parent().datetimepicker(".json_encode($this->options).');';
 
         $this->prepend('<i class="fa fa-calendar fa-fw"></i>')
             ->defaultAttribute('style', 'width: 200px');

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

@@ -44,7 +44,7 @@ class DateRange extends Field
         $startOptions = json_encode($this->options);
         $endOptions = json_encode($this->options + ['useCurrent' => false]);
 
-        $class = $this->getElementClassSelector();
+        $class = $this->elementClassSelector();
 
         $this->script = <<<JS
             $('{$class['start']}').datetimepicker($startOptions);

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

@@ -17,7 +17,7 @@ class Display extends Field
     public function render()
     {
         if ($this->callback instanceof Closure) {
-            $this->value = $this->callback->call($this->getFormModel(), $this->value());
+            $this->value = $this->callback->call($this->values(), $this->value());
         }
 
         return parent::render();

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

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

+ 2 - 2
src/Form/Field/Html.php

@@ -55,14 +55,14 @@ class Html extends Field
     public function render()
     {
         if ($this->html instanceof \Closure) {
-            $this->html = $this->html->call($this->getFormModel(), $this->form);
+            $this->html = $this->html->call($this->values(), $this->form);
         }
 
         if ($this->plain) {
             return $this->html;
         }
 
-        $viewClass = $this->getViewElementClasses();
+        $viewClass = $this->viewElementClasses();
 
         return <<<EOT
 <div class="form-group">

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

@@ -10,7 +10,7 @@ class Icon extends Text
     {
         $this->script = <<<JS
 setTimeout(function () {
-    $('{$this->getElementClassSelector()}').iconpicker({placement:'bottomLeft'});
+    $('{$this->elementClassSelector()}').iconpicker({placement:'bottomLeft'});
 }, 10);
 JS;
 

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

@@ -33,7 +33,7 @@ class Listbox extends MultipleSelect
         $settings = json_encode($settings);
 
         $this->script = <<<JS
-$("{$this->getElementClassSelector()}").bootstrapDualListbox($settings);
+$("{$this->elementClassSelector()}").bootstrapDualListbox($settings);
 JS;
 
         return parent::render();

+ 4 - 0
src/Form/Field/Nullable.php

@@ -14,4 +14,8 @@ class Nullable extends Field
     {
         return $this;
     }
+
+    public function render()
+    {
+    }
 }

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

@@ -14,7 +14,7 @@ class Number extends Text
 
         $this->script = <<<JS
 
-$('{$this->getElementClassSelector()}:not(.initialized)')
+$('{$this->elementClassSelector()}:not(.initialized)')
     .addClass('initialized')
     .bootstrapNumber({
         upClass: 'success',

+ 1 - 13
src/Form/Field/Radio.php

@@ -69,18 +69,6 @@ class Radio extends Field
         return $this;
     }
 
-    /**
-     * Set options.
-     *
-     * @param array|callable|string $values
-     *
-     * @return $this
-     */
-    public function values($values)
-    {
-        return $this->options($values);
-    }
-
     /**
      * {@inheritdoc}
      */
@@ -88,7 +76,7 @@ class Radio extends Field
     {
         if ($this->options instanceof \Closure) {
             $this->options(
-                $this->options->call($this->getFormModel(), $this->value(), $this)
+                $this->options->call($this->values(), $this->value(), $this)
             );
         }
 

+ 8 - 8
src/Form/Field/Select.php

@@ -100,8 +100,8 @@ class Select extends Field
         }
 
         $script = <<<JS
-$(document).off('change', "{$this->getElementClassSelector()}");
-$(document).on('change', "{$this->getElementClassSelector()}", function () {
+$(document).off('change', "{$this->elementClassSelector()}");
+$(document).on('change', "{$this->elementClassSelector()}", function () {
     var target = $(this).closest('.fields-group').find(".$class");
     $.get("$sourceUrl?q="+this.value, function (data) {
         target.find("option").remove();
@@ -152,8 +152,8 @@ var refreshOptions = function(url, target) {
     });
 };
 
-$(document).off('change', "{$this->getElementClassSelector()}");
-$(document).on('change', "{$this->getElementClassSelector()}", function () {
+$(document).off('change', "{$this->elementClassSelector()}");
+$(document).on('change', "{$this->elementClassSelector()}", function () {
     var _this = this;
     var promises = [];
 
@@ -244,7 +244,7 @@ JS;
 
 $.ajax($ajaxOptions).done(function(data) {
 
-  var select = $("{$this->getElementClassSelector()}");
+  var select = $("{$this->elementClassSelector()}");
 
   select.select2({
     data: data,
@@ -286,7 +286,7 @@ JS;
 
         $this->script = <<<JS
 
-$("{$this->getElementClassSelector()}").select2({
+$("{$this->elementClassSelector()}").select2({
   ajax: {
     url: "$url",
     dataType: 'json',
@@ -367,11 +367,11 @@ JS;
         $configs = json_encode($configs);
 
         if (empty($this->script)) {
-            $this->script = "$(\"{$this->getElementClassSelector()}\").select2($configs);";
+            $this->script = "$(\"{$this->elementClassSelector()}\").select2($configs);";
         }
 
         if ($this->options instanceof \Closure) {
-            $this->options = $this->options->bindTo($this->getFormModel());
+            $this->options = $this->options->bindTo($this->values());
 
             $this->options(call_user_func($this->options, $this->value(), $this));
         }

+ 5 - 5
src/Form/Field/SelectResource.php

@@ -76,7 +76,7 @@ class SelectResource extends Field
         if ($this->options instanceof \Closure) {
             $value = Helper::array(old($this->column, $this->value()));
 
-            $this->options = $this->options->call($this->getFormModel(), $value, $this);
+            $this->options = $this->options->call($this->values(), $value, $this);
         }
 
         $this->options = Helper::array($this->options);
@@ -176,13 +176,13 @@ class SelectResource extends Field
             Admin::style(".select-resource .nav li a{padding:8px 10px;font-size:13px;font-weight:bold;color:{$primayDark}}.select-resource .nav li a.red{cursor:pointer}.select-resource .nav-stacked>li{border-bottom:1px solid #eee;background: #fff;}.select-resource .nav {border: 1px solid #eee;margin-bottom:5px;}");
         }
 
-        $this->defaultAttribute('class', 'form-control '.$this->getElementClassString());
+        $this->defaultAttribute('class', 'form-control '.$this->elementClassString());
 
         $name = $this->elementName ?: $this->formatName($this->column);
 
         $this->prepend('<i class="fa fa-long-arrow-up"></i>')
             ->defaultAttribute('type', 'text')
-            ->defaultAttribute('id', $this->id.$this->getFormId())
+            ->defaultAttribute('id', $this->id.$this->formElementId())
             ->defaultAttribute('name', $name);
 
         $this->addVariables([
@@ -192,10 +192,10 @@ class SelectResource extends Field
             'area'             => json_encode($this->area),
             'maxItem'          => $this->maxItem,
             'source'           => $this->source,
-            'placeholder'      => $this->getPlaceholder(),
+            'placeholder'      => $this->placeholder(),
             'style'            => $this->style,
             'disabled'         => empty($this->attributes['disabled']) ? '' : 'disabled',
-            'inputContainerId' => $this->id.$this->getFormId(),
+            'inputContainerId' => $this->id.$this->formElementId(),
         ]);
 
         return parent::render();

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

@@ -25,7 +25,7 @@ class Slider extends Field
     {
         $option = json_encode($this->options);
 
-        $this->script = "setTimeout(function () { $('{$this->getElementClassSelector()}').ionRangeSlider($option) }, 400);";
+        $this->script = "setTimeout(function () { $('{$this->elementClassSelector()}').ionRangeSlider($option) }, 400);";
 
         return parent::render();
     }

+ 3 - 3
src/Form/Field/SwitchField.php

@@ -100,14 +100,14 @@ class SwitchField extends Field
             $this->primary();
         }
 
-        $this->attribute('name', $this->getElementName());
+        $this->attribute('name', $this->elementName());
         $this->attribute('value', 1);
         $this->attribute('type', 'checkbox');
-        $this->attribute('data-plugin', $this->getFormId().'switchery');
+        $this->attribute('data-plugin', $this->formElementId().'switchery');
 
         Admin::script(
             <<<JS
-function swty(){\$('[data-plugin="{$this->getFormId()}switchery"]').each(function(){new Switchery($(this)[0],$(this).data())})} swty();
+function swty(){\$('[data-plugin="{$this->formElementId()}switchery"]').each(function(){new Switchery($(this)[0],$(this).data())})} swty();
 JS
         );
 

+ 3 - 3
src/Form/Field/Tags.php

@@ -142,7 +142,7 @@ class Tags extends Field
     public function value($value = null)
     {
         if (is_null($value)) {
-            return empty($this->value) ? Helper::array($this->getDefault()) : $this->value;
+            return empty($this->value) ? Helper::array($this->default()) : $this->value;
         }
 
         $this->value = Helper::array($value);
@@ -159,7 +159,7 @@ class Tags extends Field
 
         if ($this->options instanceof \Closure) {
             $this->options(
-                $this->options->call($this->getFormModel(), $value, $this)
+                $this->options->call($this->values(), $value, $this)
             );
         }
 
@@ -182,7 +182,7 @@ class Tags extends Field
         // 解决部分浏览器开启 tags: true 后无法输入中文的BUG
         // 支持【逗号】【分号】【空格】结尾生成tags
         $this->script = <<<JS
-$("{$this->getElementClassSelector()}").select2({
+$("{$this->elementClassSelector()}").select2({
     tags: true,
     tokenSeparators: [',', ';', ',', ';', ' '],
     createTag: function(params) {

+ 5 - 5
src/Form/Field/Text.php

@@ -21,10 +21,10 @@ class Text extends Field
         $this->prepend('<i class="ti-pencil"></i>')
             ->defaultAttribute('type', 'text')
             ->defaultAttribute('id', $this->id)
-            ->defaultAttribute('name', $this->getElementName())
+            ->defaultAttribute('name', $this->elementName())
             ->defaultAttribute('value', old($this->column, $this->value()))
-            ->defaultAttribute('class', 'form-control '.$this->getElementClassString())
-            ->defaultAttribute('placeholder', $this->getPlaceholder());
+            ->defaultAttribute('class', 'form-control '.$this->elementClassString())
+            ->defaultAttribute('placeholder', $this->placeholder());
 
         $this->addVariables([
             'prepend' => $this->prepend,
@@ -68,7 +68,7 @@ class Text extends Field
         }
 
         $attributes = [
-            'data-match'       => '#'.$field->getElementId(),
+            'data-match'       => '#'.$field->elementId(),
             'data-match-error' => str_replace([':attribute', ':other'], [$this->label, $name], $error ?: trans('admin.validation.match')),
         ];
 
@@ -134,7 +134,7 @@ JS
     {
         $options = $this->jsonEncodeOptions($options);
 
-        $this->script = "$('{$this->getElementClassSelector()}').inputmask($options);";
+        $this->script = "$('{$this->elementClassSelector()}').inputmask($options);";
 
         return $this;
     }

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

@@ -134,7 +134,7 @@ class Tree extends Field
         $this->value = &$value;
 
         if ($this->nodes instanceof \Closure) {
-            $this->nodes = $this->nodes->call($this->getFormModel(), $this->value(), $this);
+            $this->nodes = $this->nodes->call($this->values(), $this->value(), $this);
         }
 
         if (! $this->nodes) {

+ 4 - 4
src/Form/Field/WebUploader.php

@@ -155,7 +155,7 @@ trait WebUploader
             'fileSizeLimit'       => 20971520000, // 20000M
             'fileSingleSizeLimit' => 10485760, // 10M
             'autoUpdateColumn'    => true, // 上传完图片后自动保存图片路径
-            'elementName'         => $this->getElementName(), // 字段name属性值
+            'elementName'         => $this->elementName(), // 字段name属性值
             'lang'                => trans('admin.uploader'),
 
             'deleteData' => [
@@ -176,15 +176,15 @@ trait WebUploader
 
     protected function setDefaultServer()
     {
-        if (! $this->form || ! method_exists($this->form, 'getAction')) {
+        if (! $this->form || ! method_exists($this->form, 'action')) {
             return;
         }
 
         if (empty($this->options['server'])) {
-            $this->options['server'] = $this->form->getAction();
+            $this->options['server'] = $this->form->action();
         }
         if (empty($this->options['deleteUrl'])) {
-            $this->options['deleteUrl'] = $this->form->getAction();
+            $this->options['deleteUrl'] = $this->form->action();
         }
 
         if ($this->form->builder() && $this->form->builder()->isCreating()) {

+ 8 - 8
src/Form/StepBuilder.php

@@ -188,7 +188,7 @@ class StepBuilder
     /**
      * @return DoneStep|null
      */
-    public function getDoneStep()
+    public function doneStep()
     {
         if (! $this->doneStep) {
             $this->setDefaultDonePage();
@@ -234,7 +234,7 @@ class StepBuilder
             $data = array_merge($this->fetchStash(), $data);
         }
 
-        session()->put($this->getStashKey(), $data);
+        session()->put($this->stashKey(), $data);
     }
 
     /**
@@ -248,7 +248,7 @@ class StepBuilder
             return [];
         }
 
-        return session()->get($this->getStashKey()) ?: [];
+        return session()->get($this->stashKey()) ?: [];
     }
 
     /**
@@ -262,7 +262,7 @@ class StepBuilder
             return;
         }
 
-        session()->remove($this->getStashKey());
+        session()->remove($this->stashKey());
     }
 
     /**
@@ -294,7 +294,7 @@ class StepBuilder
 
         $data = $this->fetchStash();
 
-        $data[self::CURRENT_VALIDATION_STEP] = ($this->getFieldIndex($field) ?: 0) - 1;
+        $data[self::CURRENT_VALIDATION_STEP] = ($this->fieldIndex($field) ?: 0) - 1;
 
         unset($data[self::ALL_STEPS]);
 
@@ -304,7 +304,7 @@ class StepBuilder
     /**
      * @return string
      */
-    protected function getStashKey()
+    protected function stashKey()
     {
         return 'step-form-input:'.admin_controller_slug();
     }
@@ -359,7 +359,7 @@ class StepBuilder
     protected function setAction()
     {
         foreach ($this->stepForms as $step) {
-            $step->action($this->form->getAction());
+            $step->action($this->form->action());
 
             foreach ($step->fields() as $field) {
                 if ($field instanceof Form\Field\File) {
@@ -428,7 +428,7 @@ JS;
      *
      * @return false|int
      */
-    public function getFieldIndex($column)
+    public function fieldIndex($column)
     {
         foreach ($this->stepForms as $index => $form) {
             if ($form->field($column)) {

+ 14 - 22
src/Form/StepForm.php

@@ -52,7 +52,7 @@ class StepForm extends WidgetForm
     public function __construct(Form $form, int $index = 0, string $title = null)
     {
         $this->form = $form;
-        $this->parent = $form->builder()->getStepBuilder();
+        $this->parent = $form->builder()->stepBuilder();
         $this->index = $index;
 
         $this->initFields();
@@ -63,10 +63,14 @@ class StepForm extends WidgetForm
     /**
      * @param string|\Closure $title
      *
-     * @return $this
+     * @return $this|string
      */
-    public function title($title)
+    public function title($title = null)
     {
+        if ($title === null) {
+            return $this->title;
+        }
+
         $this->title = value($title);
 
         return $this;
@@ -75,10 +79,14 @@ class StepForm extends WidgetForm
     /**
      * @param string|\Closure $content
      *
-     * @return $this
+     * @return $this|string
      */
-    public function description($content)
+    public function description($content = null)
     {
+        if ($content === null) {
+            return $this->description;
+        }
+
         $this->description = value($content);
 
         return $this;
@@ -87,27 +95,11 @@ class StepForm extends WidgetForm
     /**
      * @return int
      */
-    public function getIndex()
+    public function index()
     {
         return $this->index;
     }
 
-    /**
-     * @return string
-     */
-    public function getTitle()
-    {
-        return $this->title;
-    }
-
-    /**
-     * @return string
-     */
-    public function getDescription()
-    {
-        return $this->description;
-    }
-
     /**
      * @return string
      */

+ 1 - 1
src/Form/Tab.php

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

+ 1 - 1
src/Form/Tools.php

@@ -153,7 +153,7 @@ class Tools implements Renderable
      */
     protected function getViewPath()
     {
-        if ($key = $this->form->getResourceId()) {
+        if ($key = $this->form->resourceId()) {
             return $this->getListPath().'/'.$key;
         }
 

+ 27 - 45
src/Grid.php

@@ -183,7 +183,7 @@ class Grid
     public function __construct(?Repository $repository = null, ?\Closure $builder = null)
     {
         if ($repository) {
-            $this->keyName = $repository->getKeyName();
+            $this->keyName($repository->getKeyName());
         }
 
         $this->model = new Model(request(), $repository);
@@ -205,28 +205,24 @@ class Grid
      *
      * @return string
      */
-    public function getTableId()
+    public function tableId()
     {
         return $this->tableId;
     }
 
     /**
-     * Get primary key name of model.
-     *
-     * @return string
-     */
-    public function getKeyName()
-    {
-        return $this->keyName ?: 'id';
-    }
-
-    /**
-     * Set primary key name.
+     * Get or set primary key name.
      *
      * @param string $name
+     *
+     * @return string|void
      */
-    public function setKeyName(string $name)
+    public function keyName(string $name = null)
     {
+        if ($name === null) {
+            return $this->keyName ?: 'id';
+        }
+
         $this->keyName = $name;
     }
 
@@ -274,11 +270,11 @@ class Grid
      *
      * @param array $columns
      *
-     * @return null
+     * @return Collection|null
      */
-    public function columns($columns = [])
+    public function columns($columns = null)
     {
-        if (func_num_args() == 0) {
+        if ($columns === null) {
             return $this->columns;
         }
 
@@ -295,14 +291,6 @@ class Grid
         }
     }
 
-    /**
-     * @return Collection
-     */
-    public function getColumns()
-    {
-        return $this->columns;
-    }
-
     /**
      * Add column to grid.
      *
@@ -334,7 +322,7 @@ class Grid
     /**
      * @return array
      */
-    public function getColumnNames()
+    public function columnNames()
     {
         return $this->columnNames;
     }
@@ -382,7 +370,7 @@ class Grid
             Column::SELECT_COLUMN_NAME,
             <<<HTML
 <div class="checkbox checkbox-{$this->options['row_selector_style']} $circle checkbox-grid">
-    <input type="checkbox" class="select-all {$this->getSelectAllName()}"><label></label>
+    <input type="checkbox" class="select-all {$this->selectAllName()}"><label></label>
 </div>
 HTML
         );
@@ -479,7 +467,7 @@ HTML
      *
      * @return string
      */
-    public function getCreateUrl()
+    public function createUrl()
     {
         $queryString = '';
 
@@ -489,7 +477,7 @@ HTML
 
         return sprintf(
             '%s/create%s',
-            $this->getResource(),
+            $this->resource(),
             $queryString ? ('?'.$queryString) : ''
         );
     }
@@ -729,14 +717,20 @@ HTML;
     }
 
     /**
-     * Set resource path.
+     * Get or set resource path.
      *
      * @param string $path
      *
-     * @return $this
+     * @return $this|string
      */
-    public function resource(string $path)
+    public function resource(string $path = null)
     {
+        if ($path === null) {
+            return $this->resourcePath ?: (
+            $this->resourcePath = url(app('request')->getPathInfo())
+            );
+        }
+
         if (! empty($path)) {
             $this->resourcePath = admin_url($path);
         }
@@ -744,18 +738,6 @@ HTML;
         return $this;
     }
 
-    /**
-     * Get resource path.
-     *
-     * @return string
-     */
-    public function getResource()
-    {
-        return $this->resourcePath ?: (
-            $this->resourcePath = url(app('request')->getPathInfo())
-        );
-    }
-
     /**
      * Create a grid instance.
      *
@@ -845,7 +827,7 @@ HTML;
      * @param string $view
      * @param array  $variables
      */
-    public function setView($view, $variables = [])
+    public function view($view, $variables = [])
     {
         if (! empty($variables)) {
             $this->with($variables);

+ 3 - 3
src/Grid/Actions/Delete.php

@@ -17,15 +17,15 @@ class Delete extends RowAction
     public function render()
     {
         $this->setHtmlAttribute([
-            'data-url'    => $this->getUrl(),
+            'data-url'    => $this->url(),
             'data-action' => 'delete',
         ]);
 
         return parent::render(); // TODO: Change the autogenerated stub
     }
 
-    public function getUrl()
+    public function url()
     {
-        return "{$this->getResource()}/{$this->getKey()}";
+        return "{$this->resource()}/{$this->key()}";
     }
 }

+ 1 - 1
src/Grid/Actions/Edit.php

@@ -19,6 +19,6 @@ class Edit extends RowAction
      */
     public function href()
     {
-        return "{$this->getResource()}/{$this->getKey()}/edit";
+        return "{$this->resource()}/{$this->key()}/edit";
     }
 }

+ 2 - 2
src/Grid/Actions/QuickEdit.php

@@ -25,14 +25,14 @@ class QuickEdit extends RowAction
             [$width, $height] = $this->parent->option('dialog_form_area');
 
             Form::modal(trans('admin.edit'))
-                ->click(".{$this->getElementClass()}")
+                ->click(".{$this->elementClass()}")
                 ->dimensions($width, $height)
                 ->success('LA.reload()')
                 ->render();
         }
 
         $this->setHtmlAttribute([
-            'data-url' => "{$this->getResource()}/{$this->getKey()}/edit",
+            'data-url' => "{$this->resource()}/{$this->key()}/edit",
         ]);
 
         return parent::render(); // TODO: Change the autogenerated stub

+ 1 - 1
src/Grid/Actions/Show.php

@@ -19,6 +19,6 @@ class Show extends RowAction
      */
     public function href()
     {
-        return "{$this->getResource()}/{$this->getKey()}";
+        return "{$this->resource()}/{$this->key()}";
     }
 }

+ 1 - 1
src/Grid/Column.php

@@ -201,7 +201,7 @@ class Column
     /**
      * @return array
      */
-    public static function getExtensions()
+    public static function extensions()
     {
         return static::$displayers;
     }

+ 8 - 8
src/Grid/Column/Filter.php

@@ -33,7 +33,7 @@ abstract class Filter implements Renderable
      *
      * @return string
      */
-    public function getColumnName()
+    public function columnName()
     {
         return $this->parent->getName();
     }
@@ -41,11 +41,11 @@ abstract class Filter implements Renderable
     /**
      * @return string
      */
-    public function getFormName()
+    public function queryName()
     {
         return $this->parent->grid()->getName().
             '_filter_'.
-            $this->getColumnName();
+            $this->columnName();
     }
 
     /**
@@ -55,9 +55,9 @@ abstract class Filter implements Renderable
      *
      * @return array|\Illuminate\Http\Request|string
      */
-    public function getFilterValue($default = '')
+    public function value($default = '')
     {
-        return request($this->getFormName(), $default);
+        return request($this->queryName(), $default);
     }
 
     /**
@@ -65,13 +65,13 @@ abstract class Filter implements Renderable
      *
      * @return string
      */
-    public function getFormAction()
+    public function formAction()
     {
         $request = request();
 
         $query = $request->query();
         Arr::forget($query, [
-            $this->getColumnName(),
+            $this->columnName(),
             $this->parent->grid()->model()->getPageName(),
             '_pjax',
         ]);
@@ -89,7 +89,7 @@ abstract class Filter implements Renderable
     protected function urlWithoutFilter()
     {
         $query = app('request')->all();
-        unset($query[$this->getFormName()]);
+        unset($query[$this->queryName()]);
 
         return Helper::urlWithQuery(url()->current(), $query);
     }

+ 7 - 7
src/Grid/Column/Filter/Between.php

@@ -102,14 +102,14 @@ class Between extends Filter
         }
 
         if (! isset($value['start'])) {
-            return $model->where($this->getColumnName(), '<=', $value['end']);
+            return $model->where($this->columnName(), '<=', $value['end']);
         }
 
         if (! isset($value['end'])) {
-            return $model->where($this->getColumnName(), '=>', $value['start']);
+            return $model->where($this->columnName(), '=>', $value['start']);
         }
 
-        return $model->whereBetween($this->getColumnName(), array_values($value));
+        return $model->whereBetween($this->columnName(), array_values($value));
     }
 
     protected function addScript()
@@ -146,12 +146,12 @@ JS;
 
         $this->addScript();
 
-        $value = $this->getFilterValue(['start' => '', 'end' => '']);
+        $value = $this->value(['start' => '', 'end' => '']);
         $active = empty(array_filter($value)) ? '' : 'active';
 
         return <<<EOT
 &nbsp;<span class="dropdown" style="position:absolute">
-<form action="{$this->getFormAction()}" pjax-container style="display: inline-block;">
+<form action="{$this->formAction()}" pjax-container style="display: inline-block;">
     <a href="javascript:void(0);" class="dropdown-toggle {$active}" data-toggle="dropdown">
         <i class="fa fa-filter"></i>
     </a>
@@ -159,7 +159,7 @@ JS;
         <li>
             <input type="text" 
                 class="form-control input-sm {$this->class['start']}" 
-                name="{$this->getFormName()}[start]" 
+                name="{$this->queryName()}[start]" 
                 placeholder="{$this->trans('between_start')}" 
                 value="{$value['start']}" 
                 autocomplete="off" />
@@ -168,7 +168,7 @@ JS;
         <li>
             <input type="text" 
                 class="form-control input-sm {$this->class['start']}" 
-                name="{$this->getFormName()}[end]"  
+                name="{$this->queryName()}[end]"  
                 placeholder="{$this->trans('between_end')}" 
                 value="{$value['end']}" 
                 autocomplete="off"/>

+ 3 - 3
src/Grid/Column/Filter/Checkbox.php

@@ -30,7 +30,7 @@ JS;
 
     protected function renderCheckbox()
     {
-        $value = $this->getFilterValue([]);
+        $value = $this->value([]);
 
         $this->addScript();
 
@@ -41,7 +41,7 @@ JS;
 
         return <<<HTML
 &nbsp;<span class="dropdown" style="position:absolute;">
-<form action="{$this->getFormAction()}" pjax-container style="display: inline-block;">
+<form action="{$this->formAction()}" pjax-container style="display: inline-block;">
     <a href="javascript:void(0);" class="dropdown-toggle {$active}" data-toggle="dropdown">
         <i class="fa fa-filter"></i>
     </a>
@@ -80,7 +80,7 @@ HTML;
             return <<<HTML
 <li style="margin: 0;padding-left:5px">
     <div class="checkbox checkbox-primary checkbox-inline ">
-        <input id="$id" type="checkbox" class="{$this->class['item']}" name="{$this->getFormName()}[]" value="{$key}" {$checked}/>
+        <input id="$id" type="checkbox" class="{$this->class['item']}" name="{$this->queryName()}[]" value="{$key}" {$checked}/>
         <label for="$id">&nbsp;{$label}</label>
     </div>
 </li>

+ 1 - 1
src/Grid/Column/Filter/Equal.php

@@ -98,7 +98,7 @@ class Equal extends Filter
             return;
         }
 
-        $model->where($this->getColumnName(), $value);
+        $model->where($this->columnName(), $value);
     }
 
     /**

+ 1 - 1
src/Grid/Column/Filter/Gt.php

@@ -19,6 +19,6 @@ class Gt extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), '>', $value);
+        $model->where($this->columnName(), '>', $value);
     }
 }

+ 1 - 1
src/Grid/Column/Filter/In.php

@@ -41,7 +41,7 @@ class In extends Filter
             return;
         }
 
-        $model->whereIn($this->getColumnName(), $value);
+        $model->whereIn($this->columnName(), $value);
     }
 
     /**

+ 3 - 3
src/Grid/Column/Filter/Input.php

@@ -41,19 +41,19 @@ JS;
     {
         $this->addScript();
 
-        $value = $this->getFilterValue();
+        $value = $this->value();
 
         $active = empty($value) ? '' : 'active';
 
         return <<<HTML
 &nbsp;<span class="dropdown" style="position: absolute">
-    <form action="{$this->getFormAction()}" pjax-container style="display: inline-block;">
+    <form action="{$this->formAction()}" pjax-container style="display: inline-block;">
     <a href="javascript:void(0);" class="dropdown-toggle {$active}" data-toggle="dropdown">
         <i class="fa fa-filter"></i>
     </a>
     <ul class="dropdown-menu" role="menu" style="padding: 10px;box-shadow: 0 2px 3px 0 rgba(0,0,0,.2);left: -70px;border-radius: 0;font-weight:normal;background:#fff;">
         <li>
-            <input placeholder="{$this->placeholder}" type="text" name="{$this->getFormName()}" value="{$value}" class="form-control input-sm {$this->class}" autocomplete="off"/>
+            <input placeholder="{$this->placeholder}" type="text" name="{$this->queryName()}" value="{$value}" class="form-control input-sm {$this->class}" autocomplete="off"/>
         </li>
         <li class="divider"></li>
         <li class="">

+ 1 - 1
src/Grid/Column/Filter/Like.php

@@ -19,6 +19,6 @@ class Like extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), 'like', "%{$value}%");
+        $model->where($this->columnName(), 'like', "%{$value}%");
     }
 }

+ 1 - 1
src/Grid/Column/Filter/Lt.php

@@ -19,6 +19,6 @@ class Lt extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), '<', $value);
+        $model->where($this->columnName(), '<', $value);
     }
 }

+ 1 - 1
src/Grid/Column/Filter/Ngt.php

@@ -19,6 +19,6 @@ class Ngt extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), '<=', $value);
+        $model->where($this->columnName(), '<=', $value);
     }
 }

+ 1 - 1
src/Grid/Column/Filter/Nlt.php

@@ -19,6 +19,6 @@ class Nlt extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), '>=', $value);
+        $model->where($this->columnName(), '>=', $value);
     }
 }

+ 1 - 1
src/Grid/Column/Filter/StartWith.php

@@ -19,6 +19,6 @@ class StartWith extends Equal
             return;
         }
 
-        $model->where($this->getColumnName(), 'like', "{$value}%");
+        $model->where($this->columnName(), 'like', "{$value}%");
     }
 }

+ 1 - 1
src/Grid/Column/HasHeader.php

@@ -92,7 +92,7 @@ trait HasHeader
     public function bindFilterQuery(Model $model)
     {
         if ($this->filter) {
-            $this->filter->addBinding($this->filter->getFilterValue(), $model);
+            $this->filter->addBinding($this->filter->value(), $model);
         }
     }
 

+ 6 - 7
src/Grid/Concerns/HasElementNames.php

@@ -6,7 +6,6 @@ use Dcat\Admin\Grid;
 
 /**
  * @method Grid\Model model()
- * @method Grid\Filter getFilter()
  */
 trait HasElementNames
 {
@@ -48,7 +47,7 @@ trait HasElementNames
             ->setPageName("{$name}_{$model->getPageName()}")
             ->setSortName("{$name}_{$model->getSortName()}");
 
-        $this->getFilter()->setName($name);
+        $this->filter()->setName($name);
 
         $this->setExporterQueryName($name);
 
@@ -70,7 +69,7 @@ trait HasElementNames
     /**
      * @return string
      */
-    public function getGridRowName()
+    public function rowName()
     {
         return $this->elementNameWithPrefix('grid_row');
     }
@@ -78,7 +77,7 @@ trait HasElementNames
     /**
      * @return string
      */
-    public function getSelectAllName()
+    public function selectAllName()
     {
         return $this->elementNameWithPrefix('grid_select_all');
     }
@@ -94,7 +93,7 @@ trait HasElementNames
     /**
      * @return string
      */
-    public function getGridBatchName()
+    public function batchName()
     {
         return $this->elementNameWithPrefix('grid_batch');
     }
@@ -102,7 +101,7 @@ trait HasElementNames
     /**
      * @return string
      */
-    public function getExportSelectedName()
+    public function exportSelectedName()
     {
         return $this->elementNameWithPrefix('export_selected');
     }
@@ -110,7 +109,7 @@ trait HasElementNames
     /**
      * @return string
      */
-    public function getSelectedRowsName()
+    public function selectedRowsName()
     {
         $elementName = $this->elementNames['selected_rows'];
 

+ 8 - 8
src/Grid/Concerns/HasExporter.php

@@ -28,7 +28,7 @@ trait HasExporter
      *
      * @return Grid\Exporters\AbstractExporter
      */
-    public function exporter($exporter = null)
+    public function export($exporter = null)
     {
         $titles = [];
 
@@ -39,7 +39,7 @@ trait HasExporter
 
         $this->showExporter();
 
-        $driver = $this->exportDriver ?: ($this->exportDriver = $this->getExporter()->resolve($exporter));
+        $driver = $this->exportDriver ?: ($this->exportDriver = $this->exporter()->resolve($exporter));
 
         return $driver->titles($titles);
     }
@@ -53,7 +53,7 @@ trait HasExporter
      */
     protected function handleExportRequest($forceExport = false)
     {
-        if (! $scope = request($this->getExporter()->getQueryName())) {
+        if (! $scope = request($this->exporter()->queryName())) {
             return;
         }
 
@@ -76,7 +76,7 @@ trait HasExporter
     /**
      * @return Exporter
      */
-    public function getExporter()
+    public function exporter()
     {
         return $this->exporter ?: ($this->exporter = new Exporter($this));
     }
@@ -90,7 +90,7 @@ trait HasExporter
             return;
         }
 
-        $this->getExporter()->setQueryName($gridName.'_export_');
+        $this->exporter()->setQueryName($gridName.'_export_');
     }
 
     /**
@@ -101,7 +101,7 @@ trait HasExporter
     protected function resolveExportDriver($scope)
     {
         if (! $this->exportDriver) {
-            $this->exportDriver = $this->getExporter()->resolve();
+            $this->exportDriver = $this->exporter()->resolve();
         }
 
         return $this->exportDriver->withScope($scope);
@@ -117,13 +117,13 @@ trait HasExporter
      */
     public function getExportUrl($scope = 1, $args = null)
     {
-        $input = array_merge(request()->all(), $this->getExporter()->formatExportQuery($scope, $args));
+        $input = array_merge(request()->all(), $this->exporter()->formatExportQuery($scope, $args));
 
         if ($constraints = $this->model()->getConstraints()) {
             $input = array_merge($input, $constraints);
         }
 
-        return $this->getResource().'?'.http_build_query($input);
+        return $this->resource().'?'.http_build_query($input);
     }
 
     /**

+ 7 - 13
src/Grid/Concerns/HasFilter.php

@@ -25,16 +25,6 @@ trait HasFilter
         $this->filter = new Grid\Filter($this->model());
     }
 
-    /**
-     * Get filter of Grid.
-     *
-     * @return Grid\Filter
-     */
-    public function getFilter()
-    {
-        return $this->filter;
-    }
-
     /**
      * Process the grid filter.
      *
@@ -56,14 +46,18 @@ trait HasFilter
     }
 
     /**
-     * Set the grid filter.
+     * Get or set the grid filter.
      *
      * @param Closure $callback
      *
-     * @return $this
+     * @return $this|Grid\Filter
      */
-    public function filter(Closure $callback)
+    public function filter(Closure $callback = null)
     {
+        if ($callback === null) {
+            return $this->filter;
+        }
+
         call_user_func($callback, $this->filter);
 
         return $this;

+ 1 - 1
src/Grid/Concerns/HasMultipleHeader.php

@@ -58,7 +58,7 @@ trait HasMultipleHeader
         foreach ($originalHeaders as $header) {
             $headersColumns = array_merge(
                 $headersColumns,
-                $tmp = $header->getColumnNames()
+                $tmp = $header->columnNames()
             );
             foreach ($tmp as &$name) {
                 if ($column = $originalColumns->get($name)) {

+ 1 - 1
src/Grid/Concerns/HasQuickSearch.php

@@ -91,7 +91,7 @@ trait HasQuickSearch
             return;
         }
 
-        if (! $query = request()->get($this->quickSearch->getQueryName())) {
+        if (! $query = request()->get($this->quickSearch->queryName())) {
             return;
         }
 

+ 7 - 11
src/Grid/Concerns/HasSelector.php

@@ -18,10 +18,14 @@ trait HasSelector
     /**
      * @param \Closure $closure
      *
-     * @return $this
+     * @return $this|Selector
      */
-    public function selector(\Closure $closure)
+    public function selector(\Closure $closure = null)
     {
+        if ($closure === null) {
+            return $this->_selector;
+        }
+
         $this->_selector = new Selector($this);
 
         call_user_func($closure, $this->_selector);
@@ -46,7 +50,7 @@ trait HasSelector
 
         $active = $this->_selector->parseSelected();
 
-        $this->_selector->getSelectors()->each(function ($selector, $column) use ($active) {
+        $this->_selector->all()->each(function ($selector, $column) use ($active) {
             if (! array_key_exists($column, $active)) {
                 return;
             }
@@ -66,14 +70,6 @@ trait HasSelector
         return $this;
     }
 
-    /**
-     * @return Selector
-     */
-    public function getSelector()
-    {
-        return $this->_selector;
-    }
-
     /**
      * Render grid selector.
      *

+ 8 - 12
src/Grid/Concerns/HasTools.php

@@ -23,22 +23,18 @@ trait HasTools
     }
 
     /**
-     * @return Tools
-     */
-    public function getTools()
-    {
-        return $this->tools;
-    }
-
-    /**
-     * Setup grid tools.
+     * Get or setup grid tools.
      *
      * @param Closure $callback
      *
-     * @return $this
+     * @return $this|Tools
      */
-    public function tools(Closure $callback)
+    public function tools(Closure $callback = null)
     {
+        if ($callback === null) {
+            return $this->tools;
+        }
+
         call_user_func($callback, $this->tools);
 
         return $this;
@@ -180,7 +176,7 @@ trait HasTools
         if (
             $this->option('show_toolbar')
             && (
-                $this->getTools()->has()
+                $this->tools()->has()
                 || $this->allowExporter()
                 || $this->allowCreateBtn()
                 || $this->allowQuickCreateBtn()

+ 5 - 5
src/Grid/Displayers/AbstractDisplayer.php

@@ -76,7 +76,7 @@ abstract class AbstractDisplayer
     /**
      * @return string
      */
-    public function getElementName()
+    public function elementName()
     {
         $name = explode('.', $this->column->getName());
 
@@ -97,9 +97,9 @@ abstract class AbstractDisplayer
      *
      * @return mixed
      */
-    public function getKey()
+    public function key()
     {
-        return $this->row->get($this->grid->getKeyName());
+        return $this->row->get($this->grid->keyName());
     }
 
     /**
@@ -107,9 +107,9 @@ abstract class AbstractDisplayer
      *
      * @return string
      */
-    public function getResource()
+    public function resource()
     {
-        return $this->grid->getResource();
+        return $this->grid->resource();
     }
 
     /**

+ 7 - 7
src/Grid/Displayers/Actions.php

@@ -142,9 +142,9 @@ class Actions extends AbstractDisplayer
      *
      * @return string
      */
-    public function getResource()
+    public function resource()
     {
-        return $this->resource ?: parent::getResource();
+        return $this->resource ?: parent::resource();
     }
 
     /**
@@ -187,7 +187,7 @@ class Actions extends AbstractDisplayer
     protected function renderView()
     {
         return <<<EOT
-<a href="{$this->getResource()}/{$this->getKey()}">
+<a href="{$this->resource()}/{$this->key()}">
     <i class="ti-eye grid-action-icon"></i>
 </a>&nbsp;
 EOT;
@@ -201,7 +201,7 @@ EOT;
     protected function renderEdit()
     {
         return <<<EOT
-<a href="{$this->getResource()}/{$this->getKey()}/edit">
+<a href="{$this->resource()}/{$this->key()}/edit">
     <i class="ti-pencil-alt grid-action-icon"></i>
 </a>&nbsp;
 EOT;
@@ -218,14 +218,14 @@ EOT;
             [$width, $height] = $this->grid->option('dialog_form_area');
 
             Form::modal(trans('admin.edit'))
-                ->click(".{$this->grid->getGridRowName()}-edit")
+                ->click(".{$this->grid->rowName()}-edit")
                 ->dimensions($width, $height)
                 ->success('LA.reload()')
                 ->render();
         }
 
         return <<<EOF
-<a class="{$this->grid->getGridRowName()}-edit" data-url="{$this->getResource()}/{$this->getKey()}/edit" href="javascript:void(0);">
+<a class="{$this->grid->rowName()}-edit" data-url="{$this->resource()}/{$this->key()}/edit" href="javascript:void(0);">
     <i class=" fa fa-clone grid-action-icon"></i>
 </a>&nbsp;
 EOF;
@@ -239,7 +239,7 @@ EOF;
     protected function renderDelete()
     {
         return <<<EOT
-<a href="javascript:void(0);" data-url="{$this->getResource()}/{$this->getKey()}" data-action="delete">
+<a href="javascript:void(0);" data-url="{$this->resource()}/{$this->key()}" data-action="delete">
     <i class="ti-trash grid-action-icon"></i>
 </a>&nbsp;
 EOT;

+ 2 - 2
src/Grid/Displayers/Checkbox.php

@@ -40,7 +40,7 @@ EOT;
         Admin::script($this->script());
 
         return <<<EOT
-<form class="form-group grid-checkbox-$name" style="text-align:left;" data-key="{$this->getKey()}">
+<form class="form-group grid-checkbox-$name" style="text-align:left;" data-key="{$this->key()}">
     $radios
     <button type="submit" class="btn btn-primary btn-xs pull-left">
         <i class="fa fa-save"></i>&nbsp;{$this->trans('save')}
@@ -75,7 +75,7 @@ $('form.grid-checkbox-$name').on('submit', function () {
     };
     
     $.ajax({
-        url: "{$this->getResource()}/" + $(this).data('key'),
+        url: "{$this->resource()}/" + $(this).data('key'),
         type: "POST",
         contentType: 'application/json;charset=utf-8',
         data: JSON.stringify(data),

+ 1 - 1
src/Grid/Displayers/DropdownActions.php

@@ -37,7 +37,7 @@ class DropdownActions extends Actions
     protected function addScript()
     {
         $background = $this->grid->option('row_selector_bg') ?: Color::dark20();
-        $checkbox = ".{$this->grid->getGridRowName()}-checkbox";
+        $checkbox = ".{$this->grid->rowName()}-checkbox";
 
         $script = <<<JS
 $(function() {

+ 2 - 2
src/Grid/Displayers/Editable.php

@@ -209,8 +209,8 @@ JS
             'href'       => '#',
             'class'      => "$class",
             'data-type'  => $this->type,
-            'data-pk'    => "{$this->getKey()}",
-            'data-url'   => "{$this->getResource()}/{$this->getKey()}",
+            'data-pk'    => "{$this->key()}",
+            'data-url'   => "{$this->resource()}/{$this->key()}",
             'data-value' => "{$this->value}",
         ];
 

+ 1 - 1
src/Grid/Displayers/Expand.php

@@ -54,7 +54,7 @@ EOT;
      */
     protected function getDataKey()
     {
-        $key = $this->getKey();
+        $key = $this->key();
 
         static::$counter[$key] = static::$counter[$key] ?? 0;
         static::$counter[$key]++;

+ 1 - 1
src/Grid/Displayers/Modal.php

@@ -20,7 +20,7 @@ class Modal extends AbstractDisplayer
             $html = Helper::render($callback($this));
         }
 
-        $key = $this->grid->getName().$this->getKey();
+        $key = $this->grid->getName().$this->key();
 
         return <<<EOT
 <span class="grid-expand" data-toggle="modal" data-target="#grid-modal-{$key}">

+ 4 - 4
src/Grid/Displayers/Orderable.php

@@ -24,10 +24,10 @@ class Orderable extends AbstractDisplayer
         return <<<EOT
 
 <div class="">
-    <a href="javascript:void(0)" class=" font-14 {$this->grid->getGridRowName()}-orderable" data-id="{$this->getKey()}" data-direction="1">
+    <a href="javascript:void(0)" class=" font-14 {$this->grid->rowName()}-orderable" data-id="{$this->key()}" data-direction="1">
         <i class="fa fa-hand-o-up fa-fw"></i>
     </a>
-    <a href="javascript:void(0)" class=" font-14 {$this->grid->getGridRowName()}-orderable" data-id="{$this->getKey()}" data-direction="0">
+    <a href="javascript:void(0)" class=" font-14 {$this->grid->rowName()}-orderable" data-id="{$this->key()}" data-direction="0">
         <i class="fa fa-hand-o-down fa-fw"></i>
     </a>
 </div>
@@ -38,12 +38,12 @@ EOT;
     {
         return <<<JS
 
-$('.{$this->grid->getGridRowName()}-orderable').on('click', function() {
+$('.{$this->grid->rowName()}-orderable').on('click', function() {
 
     var key = $(this).data('id');
     var direction = $(this).data('direction');
 
-    $.post('{$this->getResource()}/' + key, {_method:'PUT', _token:LA.token, _orderable:direction}, function(data){
+    $.post('{$this->resource()}/' + key, {_method:'PUT', _token:LA.token, _orderable:direction}, function(data){
         if (data.status) {
             LA.reload();
             LA.success(data.message);

+ 2 - 2
src/Grid/Displayers/Radio.php

@@ -30,7 +30,7 @@ EOT;
         Admin::script($this->script());
 
         return <<<EOT
-<form class="form-group grid-radio-$name" style="text-align: left" data-key="{$this->getKey()}">
+<form class="form-group grid-radio-$name" style="text-align: left" data-key="{$this->key()}">
     $radios
     <button type="submit" class="btn btn-primary btn-xs pull-left">
         <i class="fa fa-save"></i>&nbsp;{$this->trans('save')}
@@ -57,7 +57,7 @@ $('form.grid-radio-$name').on('submit', function () {
     btn.button('loading');
 
     $.ajax({
-        url: "{$this->getResource()}/" + $(this).data('key'),
+        url: "{$this->resource()}/" + $(this).data('key'),
         type: "POST",
         data: {
             $name: value,

+ 7 - 7
src/Grid/Displayers/RowSelector.php

@@ -16,7 +16,7 @@ class RowSelector extends AbstractDisplayer
 
         return <<<EOT
 <div class="checkbox $circle checkbox-$style checkbox-grid">
-    <input type="checkbox" class="{$this->grid->getGridRowName()}-checkbox" data-id="{$this->getKey()}" data-label="{$this->getLabel()}">
+    <input type="checkbox" class="{$this->grid->rowName()}-checkbox" data-id="{$this->key()}" data-label="{$this->label()}">
     <label></label>
 </div>
 EOT;
@@ -30,9 +30,9 @@ EOT;
         Admin::script(
             <<<JS
 LA.RowSelector({
-    checkbox: '.{$this->grid->getGridRowName()}-checkbox',
-    selectAll: '.{$this->grid->getSelectAllName()}', 
-    getSelectedRowsMethod: '{$this->grid->getSelectedRowsName()}',
+    checkbox: '.{$this->grid->rowName()}-checkbox',
+    selectAll: '.{$this->grid->selectAllName()}', 
+    getSelectedRowsMethod: '{$this->grid->selectedRowsName()}',
     clickTr: {$clickTr},
     bg: '{$background}',
 });
@@ -40,7 +40,7 @@ JS
         );
     }
 
-    protected function getLabel()
+    protected function label()
     {
         if ($column = $this->grid->option('row_selector_label_key')) {
             $label = $this->row->{$column};
@@ -48,11 +48,11 @@ JS
                 return $label;
             }
 
-            return $this->getKey();
+            return $this->key();
         }
 
         $label = $this->row->name ?: $this->row->title;
 
-        return $label ?: ($this->row->username ?: $this->getKey());
+        return $label ?: ($this->row->username ?: $this->key());
     }
 }

+ 2 - 2
src/Grid/Displayers/Select.php

@@ -23,7 +23,7 @@ $('.$class').select2().on('change', function(){
     var value = $(this).val();
     LA.NP.start();
     $.ajax({
-        url: "{$this->getResource()}/" + pk,
+        url: "{$this->resource()}/" + pk,
         type: "POST",
         data: {
             $name: value,
@@ -41,7 +41,7 @@ JS;
 
         Admin::script($script);
 
-        $key = $this->row->{$this->grid->getKeyName()};
+        $key = $this->row->{$this->grid->keyName()};
 
         $optionsHtml = '';
 

+ 3 - 3
src/Grid/Displayers/SwitchDisplay.php

@@ -70,8 +70,8 @@ class SwitchDisplay extends AbstractDisplayer
 
         $this->setupScript();
 
-        $name = $this->getElementName();
-        $key = $this->row->{$this->grid->getKeyName()};
+        $name = $this->elementName();
+        $key = $this->row->{$this->grid->keyName()};
         $checked = $this->value ? 'checked' : '';
         $color = $this->color ?: Color::primary();
 
@@ -102,7 +102,7 @@ EOF;
         LA.NP.start();
     
         $.ajax({
-            url: "{$this->getResource()}/" + id,
+            url: "{$this->resource()}/" + id,
             type: "POST",
             data: data,
             success: function (d) {

+ 2 - 2
src/Grid/Displayers/SwitchGroup.php

@@ -67,7 +67,7 @@ class SwitchGroup extends SwitchDisplay
         LA.NP.start();
     
          $.ajax({
-            url: "{$this->grid->getResource()}/" + id,
+            url: "{$this->resource()}/" + id,
             type: "POST",
             data: data,
             success: function (d) {
@@ -84,7 +84,7 @@ class SwitchGroup extends SwitchDisplay
 JS;
         Admin::script($script);
 
-        $key = $this->row->{$this->grid->getKeyName()};
+        $key = $this->row->{$this->grid->keyName()};
         $checked = $this->row->$name ? 'checked' : '';
 
         return <<<EOT

+ 5 - 5
src/Grid/Exporter.php

@@ -137,7 +137,7 @@ class Exporter
      *
      * @return string
      */
-    public function getQueryName(): string
+    public function queryName(): string
     {
         return $this->queryName;
     }
@@ -170,7 +170,7 @@ class Exporter
             return $driver;
         }
 
-        return $this->getExporter($driver);
+        return $this->exporter($driver);
     }
 
     /**
@@ -180,10 +180,10 @@ class Exporter
      *
      * @return Grid\Exporters\AbstractExporter
      */
-    protected function getExporter($driver): ExporterInterface
+    protected function exporter($driver): ExporterInterface
     {
         if (! $driver || ! array_key_exists($driver, static::$drivers)) {
-            return $this->getDefaultExporter();
+            return $this->makeDefaultExporter();
         }
 
         $driver = new static::$drivers[$driver]();
@@ -200,7 +200,7 @@ class Exporter
      *
      * @return Grid\Exporters\ExcelExporter
      */
-    public function getDefaultExporter()
+    public function makeDefaultExporter()
     {
         return Grid\Exporters\ExcelExporter::make()->setGrid($this->grid);
     }

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

@@ -166,7 +166,7 @@ abstract class AbstractExporter implements ExporterInterface
     public function setGrid(Grid $grid)
     {
         $this->grid = $grid;
-        $this->parent = $grid->getExporter();
+        $this->parent = $grid->exporter();
 
         return $this;
     }
@@ -209,7 +209,7 @@ abstract class AbstractExporter implements ExporterInterface
             $model->forPage($page, $perPage);
         }
 
-        $array = $this->grid->getFilter()->execute(true);
+        $array = $this->grid->filter()->execute(true);
 
         $model->reset();
         $model->rejectQueries('forPage');
@@ -247,7 +247,7 @@ abstract class AbstractExporter implements ExporterInterface
         if ($scope == Grid\Exporter::SCOPE_SELECTED_ROWS) {
             $selected = explode(',', $args);
 
-            $this->grid->model()->whereIn($this->grid->getKeyName(), $selected);
+            $this->grid->model()->whereIn($this->grid->keyName(), $selected);
         }
 
         return $this;

+ 16 - 16
src/Grid/Filter.php

@@ -108,7 +108,7 @@ class Filter implements Renderable
     protected $model;
 
     /**
-     * @var array
+     * @var AbstractFilter[]
      */
     protected $filters = [];
 
@@ -280,7 +280,7 @@ class Filter implements Renderable
      */
     public function input($key = null, $default = null)
     {
-        $inputs = $this->getInputs();
+        $inputs = $this->inputs();
 
         if ($key === null) {
             return $inputs;
@@ -294,7 +294,7 @@ class Filter implements Renderable
      *
      * @return Model
      */
-    public function getModel()
+    public function model()
     {
         return $this->model;
     }
@@ -304,7 +304,7 @@ class Filter implements Renderable
      *
      * @return \Dcat\Admin\Grid
      */
-    public function getGrid()
+    public function grid()
     {
         return $this->model->getGrid();
     }
@@ -328,7 +328,7 @@ class Filter implements Renderable
      *
      * @return string
      */
-    public function getFilterID()
+    public function filterID()
     {
         return $this->filterID;
     }
@@ -376,17 +376,17 @@ class Filter implements Renderable
     {
         $this->filters = array_filter($this->filters, function (AbstractFilter $filter) use (&$column) {
             if (is_array($column)) {
-                return ! in_array($filter->getColumn(), $column);
+                return ! in_array($filter->column(), $column);
             }
 
-            return $filter->getColumn() != $column;
+            return $filter->column() != $column;
         });
     }
 
     /**
      * @return array
      */
-    public function getInputs()
+    public function inputs()
     {
         if (! is_null($this->inputs)) {
             return $this->inputs;
@@ -410,7 +410,7 @@ class Filter implements Renderable
      */
     public function conditions()
     {
-        $inputs = $this->getInputs();
+        $inputs = $this->inputs();
 
         if (empty($inputs)) {
             return [];
@@ -513,7 +513,7 @@ class Filter implements Renderable
      *
      * @return Collection
      */
-    public function getScopes()
+    public function scopes()
     {
         return $this->scopes;
     }
@@ -523,7 +523,7 @@ class Filter implements Renderable
      *
      * @return Scope|null
      */
-    public function getCurrentScope()
+    public function currentScope()
     {
         $key = request(Scope::QUERY_NAME);
 
@@ -537,7 +537,7 @@ class Filter implements Renderable
      *
      * @return string
      */
-    public function getCurrentScopeName()
+    public function currentScopeName()
     {
         return request(Scope::QUERY_NAME);
     }
@@ -549,7 +549,7 @@ class Filter implements Renderable
      */
     protected function scopeConditions()
     {
-        if ($scope = $this->getCurrentScope()) {
+        if ($scope = $this->currentScope()) {
             return $scope->condition();
         }
 
@@ -655,11 +655,11 @@ class Filter implements Renderable
     public function urlWithoutFilters()
     {
         /** @var Collection $columns */
-        $columns = collect($this->filters)->map->getColumn()->flatten();
+        $columns = collect($this->filters)->map->column()->flatten();
 
         $pageKey = 'page';
 
-        if ($gridName = $this->model->getGrid()->getName()) {
+        if ($gridName = $this->model->grid()->getName()) {
             $pageKey = "{$gridName}_{$pageKey}";
         }
 
@@ -751,7 +751,7 @@ class Filter implements Renderable
     /**
      * @return array
      */
-    public static function getExtensions()
+    public static function extensions()
     {
         return static::$supports;
     }

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

@@ -458,7 +458,7 @@ abstract class AbstractFilter
      *
      * @return string
      */
-    public function getColumn()
+    public function column()
     {
         $parenName = $this->parent->getName();
 
@@ -506,7 +506,7 @@ abstract class AbstractFilter
     {
         $variables = $this->presenter()->variables();
 
-        $value = $this->value ?: Arr::get($this->parent->getInputs(), $this->column);
+        $value = $this->value ?: Arr::get($this->parent->inputs(), $this->column);
 
         return array_merge([
             'id'        => $this->id,

+ 1 - 1
src/Grid/Filter/Presenter/MultipleSelect.php

@@ -18,7 +18,7 @@ class MultipleSelect extends Select
      */
     public function loadMore($target, $resourceUrl, $idField = 'id', $textField = 'text'): self
     {
-        $column = $this->filter->getColumn();
+        $column = $this->filter->column();
 
         $script = <<<JS
 

+ 7 - 7
src/Grid/Filter/Presenter/Select.php

@@ -106,7 +106,7 @@ class Select extends Presenter
             $configs = substr($configs, 1, strlen($configs) - 2);
 
             $this->script = <<<SCRIPT
-$(".{$this->getElementClass()}").select2({
+$(".{$this->elementClass()}").select2({
   placeholder: $placeholder,
   $configs
 });
@@ -193,7 +193,7 @@ SCRIPT;
         $this->script = <<<JS
 
 $.ajax($ajaxOptions).done(function(data) {
-  $(".{$this->getElementClass()}").select2({
+  $(".{$this->elementClass()}").select2({
     data: data,
     $configs
   }).val($values).trigger("change");
@@ -223,7 +223,7 @@ JS;
 
         $this->script = <<<JS
 
-$(".{$this->getElementClass()}").select2({
+$(".{$this->elementClass()}").select2({
   ajax: {
     url: "$resourceUrl",
     dataType: 'json',
@@ -266,7 +266,7 @@ JS;
     {
         return [
             'options'   => $this->buildOptions(),
-            'class'     => $this->getElementClass(),
+            'class'     => $this->elementClass(),
             'selectAll' => $this->selectAll,
         ];
     }
@@ -274,10 +274,10 @@ JS;
     /**
      * @return string
      */
-    protected function getElementClass() : string
+    protected function elementClass() : string
     {
         return $this->elementClass ?:
-            ($this->elementClass = $this->getClass($this->filter->getColumn()));
+            ($this->elementClass = $this->getClass($this->filter->column()));
     }
 
     /**
@@ -292,7 +292,7 @@ JS;
      */
     public function load($target, $resourceUrl, $idField = 'id', $textField = 'text') : self
     {
-        $class = $this->getElementClass();
+        $class = $this->elementClass();
 
         $script = <<<JS
 $(document).off('change', ".{$class}");

+ 2 - 2
src/Grid/Filter/Presenter/SelectResource.php

@@ -159,7 +159,7 @@ class SelectResource extends Presenter
     protected function setDefaultSource()
     {
         if (! $this->source) {
-            $column = $this->filter->getColumn();
+            $column = $this->filter->column();
             if (strpos($column, '.')) {
                 $this->path(str_replace('_id', '', last(explode('.', $column))));
             } else {
@@ -174,7 +174,7 @@ class SelectResource extends Presenter
     public function variables() : array
     {
         $this->value = request(
-            $this->filter->getColumn(),
+            $this->filter->column(),
             $this->filter->getValue() ?: $this->filter->getDefault()
         );
 

+ 3 - 3
src/Grid/GridAction.php

@@ -55,15 +55,15 @@ abstract class GridAction implements Renderable
      *
      * @return string
      */
-    public function getResource()
+    public function resource()
     {
-        return $this->parent->getResource();
+        return $this->parent->resource();
     }
 
     /**
      * @return string
      */
-    protected function getElementClass()
+    protected function elementClass()
     {
         return ltrim($this->selector($this->selectorPrefix), '.');
     }

+ 1 - 1
src/Grid/Header.php

@@ -40,7 +40,7 @@ class Header extends Widget
     /**
      * @return array
      */
-    public function getColumnNames()
+    public function columnNames()
     {
         return $this->columnNames;
     }

+ 4 - 4
src/Grid/Model.php

@@ -177,7 +177,7 @@ class Model
      */
     public function getKeyName()
     {
-        return $this->grid->getKeyName();
+        return $this->grid->keyName();
     }
 
     /**
@@ -285,7 +285,7 @@ class Model
      *
      * @return Grid
      */
-    public function getGrid()
+    public function grid()
     {
         return $this->grid;
     }
@@ -295,9 +295,9 @@ class Model
      *
      * @return Filter
      */
-    public function getFilter()
+    public function filter()
     {
-        return $this->grid->getFilter();
+        return $this->grid->filter();
     }
 
     /**

+ 1 - 1
src/Grid/Responsive.php

@@ -48,7 +48,7 @@ class Responsive
      */
     public function all()
     {
-        $this->grid->getColumns()->each->responsive();
+        $this->grid->columns()->each->responsive();
 
         return $this;
     }

+ 14 - 17
src/Grid/Row.php

@@ -4,11 +4,12 @@ namespace Dcat\Admin\Grid;
 
 use Closure;
 use Dcat\Admin\Grid;
+use Dcat\Admin\Support\Helper;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Jsonable;
 use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Arr;
+use Illuminate\Support\Fluent;
 
 class Row implements Arrayable
 {
@@ -20,7 +21,7 @@ class Row implements Arrayable
     /**
      * Row data.
      *
-     * @var
+     * @var Fluent
      */
     protected $data;
 
@@ -34,7 +35,7 @@ class Row implements Arrayable
     public function __construct(Grid $grid, $data)
     {
         $this->grid = $grid;
-        $this->data = $data;
+        $this->data = new Fluent(Helper::array($data));
     }
 
     /**
@@ -42,9 +43,9 @@ class Row implements Arrayable
      *
      * @return mixed
      */
-    public function getKey()
+    public function key()
     {
-        return $this->model->getKey();
+        return $this->data->get($this->grid->keyName());
     }
 
     /**
@@ -52,7 +53,7 @@ class Row implements Arrayable
      *
      * @return string
      */
-    public function getRowAttributes()
+    public function rowAttributes()
     {
         return $this->formatHtmlAttributes($this->attributes);
     }
@@ -64,10 +65,10 @@ class Row implements Arrayable
      *
      * @return string
      */
-    public function getColumnAttributes($column)
+    public function columnAttributes($column)
     {
         if (
-            ($column = $this->grid->getColumns()->get($column))
+            ($column = $this->grid->columns()->get($column))
             && ($attributes = $column->getAttributes())
         ) {
             return $this->formatHtmlAttributes($attributes);
@@ -140,7 +141,7 @@ class Row implements Arrayable
      */
     public function __get($attr)
     {
-        return Arr::get($this->data, $attr);
+        return $this->data->get($attr);
     }
 
     /**
@@ -153,7 +154,7 @@ class Row implements Arrayable
      */
     public function __set($attr, $value)
     {
-        Arr::set($this->data, $attr, $value);
+        $this->data[$attr] = $value;
     }
 
     /**
@@ -167,7 +168,7 @@ class Row implements Arrayable
     public function column($name, $value = null)
     {
         if (is_null($value)) {
-            $column = Arr::get($this->data, $name);
+            $column = $this->data->get($name);
 
             return $this->output($column);
         }
@@ -176,7 +177,7 @@ class Row implements Arrayable
             $value = $value->call($this, $this->column($name));
         }
 
-        Arr::set($this->data, $name, $value);
+        $this->data[$name] = $value;
 
         return $this;
     }
@@ -186,11 +187,7 @@ class Row implements Arrayable
      */
     public function toArray()
     {
-        if ($this->data instanceof Arrayable) {
-            return $this->data->toArray();
-        }
-
-        return (array) $this->data;
+        return $this->data->toArray();
     }
 
     /**

+ 4 - 4
src/Grid/RowAction.php

@@ -26,9 +26,9 @@ abstract class RowAction extends GridAction
      *
      * @return mixed
      */
-    protected function getKey()
+    protected function key()
     {
-        return $this->row->get($this->parent->getKeyName());
+        return $this->row->get($this->parent->keyName());
     }
 
     /**
@@ -102,9 +102,9 @@ abstract class RowAction extends GridAction
 
         return sprintf(
             "<a data-_key='%s' href='%s' class='%s' {$attributes}>%s</a>",
-            $this->getKey(),
+            $this->key(),
             $href,
-            $this->getElementClass(),
+            $this->elementClass(),
             $this->name()
         );
     }

+ 17 - 19
src/Grid/Tools/BatchAction.php

@@ -30,24 +30,22 @@ abstract class BatchAction implements Renderable
     /**
      * @param $id
      */
-    public function setId($id)
+    public function id($id = null)
     {
+        if ($id === null) {
+            return $this->id;
+        }
+
         $this->id = $id;
     }
 
-    public function setTitle($title)
+    public function title($title = null)
     {
-        $this->title = $title;
+        if ($title === null) {
+            return $this->title;
+        }
 
-        return $this;
-    }
-
-    /**
-     * @return string
-     */
-    public function getTitle()
-    {
-        return $this->title;
+        $this->title = $title;
     }
 
     /**
@@ -57,13 +55,13 @@ abstract class BatchAction implements Renderable
     {
         $this->grid = $grid;
 
-        $this->resource = $grid->getResource();
+        $this->resource = $grid->resource();
     }
 
     /**
      * @return string
      */
-    public function getToken()
+    public function token()
     {
         return csrf_token();
     }
@@ -73,11 +71,11 @@ abstract class BatchAction implements Renderable
      *
      * @return string
      */
-    public function getElementClass()
+    public function elementClass()
     {
         return sprintf(
             '%s-%s',
-            $this->grid->getGridBatchName(),
+            $this->grid->batchName(),
             $this->id
         );
     }
@@ -85,9 +83,9 @@ abstract class BatchAction implements Renderable
     /**
      * @return string
      */
-    public function getElementSelector()
+    public function elementSelector()
     {
-        return '.'.$this->getElementClass();
+        return '.'.$this->elementClass();
     }
 
     /**
@@ -100,7 +98,7 @@ abstract class BatchAction implements Renderable
     public function render()
     {
         return <<<HTML
-<li><a href="#" class="{$this->getElementClass()}">{$this->getTitle()}</a></li>
+<li><a href="#" class="{$this->elementClass()}">{$this->title()}</a></li>
 HTML;
     }
 }

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff