jqh 6 anos atrás
pai
commit
cb8968a198

+ 0 - 1
src/Admin.php

@@ -100,7 +100,6 @@ class Admin
         return static::$metaTitle ?: config('admin.title');
     }
 
-
     /**
      * @param null|string $favicon
      *

+ 1 - 0
src/Controllers/AuthController.php

@@ -175,6 +175,7 @@ class AuthController extends Controller
                 if ($v == $this->password) {
                     return;
                 }
+
                 return $v;
             });
         $form->password('password_confirmation', trans('admin.password_confirmation'))->same('password');

+ 3 - 0
src/Controllers/ExtensionController.php

@@ -162,6 +162,7 @@ class ExtensionController extends Controller
 
     /**
      * @param string $key
+     *
      * @return \Closure
      */
     protected function getExpandHandler($key = 'require')
@@ -206,9 +207,11 @@ class ExtensionController extends Controller
             if (!$v) {
                 return;
             }
+
             foreach ($v as &$item) {
                 $item = "<span class='text-80 bold'>{$item['name']}</span> <<code>{$item['email']}</code>>";
             }
+
             return implode('<br/>', $v);
         };
 

+ 0 - 2
src/Controllers/IconController.php

@@ -34,8 +34,6 @@ class IconController extends Controller
             $tab->add('Glyphicons', view('admin::helpers.glyphicons'));
 
             $row->column(12, $tab);
-
         });
     }
-
 }

+ 1 - 2
src/Controllers/LogController.php

@@ -4,8 +4,8 @@ namespace Dcat\Admin\Controllers;
 
 use Dcat\Admin\Grid;
 use Dcat\Admin\Layout\Content;
-use Dcat\Admin\Models\Repositories\OperationLog;
 use Dcat\Admin\Models\OperationLog as OperationLogModel;
+use Dcat\Admin\Models\Repositories\OperationLog;
 use Illuminate\Routing\Controller;
 use Illuminate\Support\Arr;
 
@@ -89,7 +89,6 @@ class LogController extends Controller
             $filter->between('created_at')
                 ->width(4)
                 ->datetime();
-
         });
 
         return $grid;

+ 0 - 1
src/Controllers/PermissionController.php

@@ -106,7 +106,6 @@ class PermissionController extends Controller
         return $grid;
     }
 
-
     /**
      * @return \Dcat\Admin\Tree
      */

+ 0 - 2
src/Controllers/RoleController.php

@@ -148,7 +148,6 @@ class RoleController extends Controller
             if ($show->getKey() == RoleModel::ADMINISTRATOR_ID) {
                 $show->disableDeleteButton();
             }
-
         });
     }
 
@@ -213,5 +212,4 @@ class RoleController extends Controller
 
         return $this->delete($id);
     }
-
 }

+ 1 - 4
src/Controllers/ScaffoldController.php

@@ -90,7 +90,7 @@ class ScaffoldController extends Controller
 
         $paths = [];
         $message = '';
-        
+
         $creates = (array) $request->get('create');
 
         try {
@@ -150,11 +150,8 @@ class ScaffoldController extends Controller
                     $paths['ide-helper'] = 'dcat_admin_ide_helper.php';
                 } catch (\Throwable $e) {
                 }
-
             }
-
         } catch (\Exception $exception) {
-
             // Delete generated files if exception thrown.
             app('files')->delete($paths);
 

+ 1 - 1
src/Controllers/UserController.php

@@ -176,7 +176,7 @@ class UserController extends Controller
             $show->divider();
 
             $show->roles->width(6)->as(function ($roles) {
-                if (! $roles) {
+                if (!$roles) {
                     return;
                 }
 

+ 1 - 0
src/Extension.php

@@ -286,6 +286,7 @@ abstract class Extension
 
     /**
      * @param $path
+     *
      * @return bool
      */
     protected function checkMenuExist($path)

+ 0 - 1
src/Extension/Grid/ImportButton.php

@@ -30,7 +30,6 @@ class ImportButton implements Renderable
         return <<<HTML
 <a href="javascript:void(0)" class="import-extension" data-id="{$this->row->id}">$button</a>
 HTML;
-
     }
 
     protected function setupScript()

+ 25 - 26
src/Form.php

@@ -560,7 +560,6 @@ class Form implements Renderable
         }
 
         return response()->json($response);
-
     }
 
     /**
@@ -599,7 +598,6 @@ class Form implements Renderable
         );
     }
 
-
     /**
      * Before store.
      *
@@ -623,7 +621,7 @@ class Form implements Renderable
         }
 
         if ($response = $this->handleUploadFile($data)) {
-            if (($value = $response->getData()) && ! empty($value->id)) {
+            if (($value = $response->getData()) && !empty($value->id)) {
                 $this->step()->stash(
                     [$data['upload_column'] => $value->id],
                     true
@@ -663,6 +661,7 @@ class Form implements Renderable
      * @param $message
      * @param null $redirect
      * @param bool $status
+     *
      * @return bool|\Illuminate\Http\JsonResponse
      */
     public function ajaxResponse($message, $redirect = null, bool $status = true)
@@ -679,13 +678,13 @@ class Form implements Renderable
     }
 
     /**
-     * ajax but not pjax
+     * Ajax but not pjax.
      *
      * @return bool
      */
     public function isAjaxRequest()
     {
-        return $this->request->ajax() && ! $this->request->pjax();
+        return $this->request->ajax() && !$this->request->pjax();
     }
 
     /**
@@ -775,8 +774,7 @@ class Form implements Renderable
         $id,
         ?array $data = null,
         $redirectTo = null
-    )
-    {
+    ) {
         $data = $data ?: $this->request->all();
 
         if ($response = $this->beforeUpdate($id, $data)) {
@@ -851,19 +849,19 @@ class Form implements Renderable
      */
     protected function makeValidationErrorsResponse($validationMessages)
     {
-        if (! $this->isAjaxRequest()) {
+        if (!$this->isAjaxRequest()) {
             return back()->withInput()->withErrors($validationMessages);
         }
 
         return response()->json([
-            'errors' => is_array($validationMessages) ? $validationMessages : $validationMessages->getMessages()
+            'errors' => is_array($validationMessages) ? $validationMessages : $validationMessages->getMessages(),
         ], 422);
     }
 
     /**
      * Get redirect response.
      *
-     * @param string $url
+     * @param string       $url
      * @param array|string $options
      *
      * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
@@ -892,7 +890,6 @@ class Form implements Renderable
         }
 
         return redirect($url, $status);
-
     }
 
     /**
@@ -903,7 +900,9 @@ class Form implements Renderable
      */
     public function getRedirectUrl($key, $redirectTo = null)
     {
-        if ($redirectTo) return $redirectTo;
+        if ($redirectTo) {
+            return $redirectTo;
+        }
 
         $resourcesPath = $this->builder->isCreating() ?
             $this->getResource(0) : $this->getResource(-1);
@@ -913,12 +912,15 @@ class Form implements Renderable
             if ($this->builder->isEditing() && $this->isAjaxRequest()) {
                 return false;
             }
+
             return rtrim($resourcesPath, '/')."/{$key}/edit";
         }
+
         if ($this->request->get('after-save') == 2) {
             // continue creating
             return rtrim($resourcesPath, '/').'/create';
         }
+
         if ($this->request->get('after-save') == 3) {
             // view resource
             return rtrim($resourcesPath, '/')."/{$key}";
@@ -1051,9 +1053,8 @@ class Form implements Renderable
      * Is input data is has-one relation.
      *
      * @param array $inserts
-     *
      */
-    function prepareHasOneRelation(array &$inserts)
+    public function prepareHasOneRelation(array &$inserts)
     {
         $relations = [];
         $this->builder->fields()->each(function ($field) use (&$relations) {
@@ -1082,7 +1083,6 @@ class Form implements Renderable
                 $inserts = array_merge($inserts, Arr::dot([$first => $inserts[$first]]));
             }
         }
-
     }
 
     /**
@@ -1106,7 +1106,7 @@ class Form implements Renderable
      */
     public function getKeyName()
     {
-        if (! $this->repository) {
+        if (!$this->repository) {
             return 'id';
         }
 
@@ -1118,7 +1118,7 @@ class Form implements Renderable
      */
     public function getCreatedAtColumn()
     {
-        if (! $this->repository) {
+        if (!$this->repository) {
             return;
         }
 
@@ -1130,7 +1130,7 @@ class Form implements Renderable
      */
     public function getUpdatedAtColumn()
     {
-        if (! $this->repository) {
+        if (!$this->repository) {
             return;
         }
 
@@ -1316,7 +1316,7 @@ class Form implements Renderable
 
     /**
      * @param string|array|MessageProvider $column
-     * @param string|array $messages
+     * @param string|array                 $messages
      *
      * @return $this
      */
@@ -1327,7 +1327,7 @@ class Form implements Renderable
         }
 
         if (!$this->validationMessages) {
-            $this->validationMessages = new MessageBag;
+            $this->validationMessages = new MessageBag();
         }
 
         if (!$column) {
@@ -1336,17 +1336,16 @@ class Form implements Renderable
 
         if (is_array($column)) {
             foreach ($column as $k => &$v) {
-                $v = (array)$v;
+                $v = (array) $v;
             }
             $this->validationMessages->merge($column);
         } elseif ($messages) {
-            $this->validationMessages->merge([$column => (array)$messages]);
+            $this->validationMessages->merge([$column => (array) $messages]);
         }
 
         return $this;
     }
 
-
     /**
      * Merge validation messages from input validators.
      *
@@ -1691,7 +1690,7 @@ class Form implements Renderable
     }
 
     /**
-     * @param int $width
+     * @param int     $width
      * @param Closure $callback
      */
     public function block(int $width, \Closure $callback)
@@ -1730,7 +1729,7 @@ class Form implements Renderable
      */
     public function inModal(\Closure $callback = null)
     {
-        if (! $callback) {
+        if (!$callback) {
             return ModalForm::is();
         }
 
@@ -1824,7 +1823,7 @@ class Form implements Renderable
      * Setter.
      *
      * @param string $name
-     * @param $value
+     * @param mixed  $value
      */
     public function __set($name, $value)
     {

+ 21 - 14
src/Form/Builder.php

@@ -147,16 +147,17 @@ class Builder
      */
     public function __construct(Form $form)
     {
-        $this->form   = $form;
+        $this->form = $form;
         $this->fields = new Collection();
         $this->layout = new Layout($form);
-        $this->tools  = new Tools($this);
+        $this->tools = new Tools($this);
         $this->footer = new Footer($this);
     }
 
 
     /**
      * @param \Closure $closure
+     *
      * @return Layout
      */
     public function layout($closure = null)
@@ -170,6 +171,7 @@ class Builder
 
     /**
      * @param Closure $closure
+     *
      * @return $this;
      */
     public function wrap(Closure $closure)
@@ -189,6 +191,7 @@ class Builder
 
     /**
      * @param int $width
+     *
      * @return $this
      */
     public function setDefaultBlockWidth(int $width)
@@ -234,11 +237,12 @@ class Builder
 
     /**
      * @param \Closure $callback
+     *
      * @return StepBuilder
      */
     public function step(?\Closure $callback = null)
     {
-        if (! $this->stepBuilder) {
+        if (!$this->stepBuilder) {
             $this->view = 'admin::form.steps';
 
             $this->stepBuilder = new StepBuilder($this->form);
@@ -470,11 +474,12 @@ class Builder
 
     /**
      * @param string $name
+     *
      * @return Field|null
      */
     public function stepField($name)
     {
-        if (! $builder = $this->getStepBuilder()) {
+        if (!$builder = $this->getStepBuilder()) {
             return;
         }
 
@@ -492,7 +497,7 @@ class Builder
     {
         $fields = new Collection();
 
-        if (! $builder = $this->getStepBuilder()) {
+        if (!$builder = $this->getStepBuilder()) {
             return $fields;
         }
 
@@ -505,6 +510,7 @@ class Builder
 
     /**
      * @param $column
+     *
      * @return void
      */
     public function removeField($column)
@@ -587,6 +593,7 @@ class Builder
 
     /**
      * @param bool $disable
+     *
      * @return void
      */
     public function disableHeader(bool $disable = true)
@@ -596,6 +603,7 @@ class Builder
 
     /**
      * @param bool $disable
+     *
      * @return void
      */
     public function disableFooter(bool $disable = true)
@@ -605,6 +613,7 @@ class Builder
 
     /**
      * @param $id
+     *
      * @return void
      */
     public function setFormId($id)
@@ -688,18 +697,18 @@ class Builder
     {
         $attributes = [];
 
-        if ($this->isMode(self::MODE_EDIT)) {
+        if ($this->isMode(static::MODE_EDIT)) {
             $this->addHiddenField((new Hidden('_method'))->value('PUT'));
         }
 
         $this->addRedirectUrlField();
 
-        $attributes['id']             = $this->getFormId();
-        $attributes['action']         = $this->getAction();
-        $attributes['method']         = Arr::get($options, 'method', 'post');
+        $attributes['id'] = $this->getFormId();
+        $attributes['action'] = $this->getAction();
+        $attributes['method'] = Arr::get($options, 'method', 'post');
         $attributes['accept-charset'] = 'UTF-8';
-        $attributes['data-toggle']    = 'validator';
-        $attributes['class']          = Arr::get($options, 'class');
+        $attributes['data-toggle'] = 'validator';
+        $attributes['class'] = Arr::get($options, 'class');
 
         if ($this->hasFile()) {
             $attributes['enctype'] = 'multipart/form-data';
@@ -733,7 +742,7 @@ class Builder
      */
     protected function removeReservedFields()
     {
-        if (! $this->isMode(static::MODE_CREATE)) {
+        if (!$this->isMode(static::MODE_CREATE)) {
             return;
         }
 
@@ -811,7 +820,6 @@ class Builder
         return <<<EOF
 {$open} {$this->layout->build()} {$this->close()}
 EOF;
-
     }
 
     /**
@@ -859,7 +867,6 @@ EOF;
     });
 })()
 JS
-
         );
     }
 

+ 8 - 7
src/Form/Concerns/HasEvents.php

@@ -31,7 +31,7 @@ trait HasEvents
     public function creating(Closure $callback)
     {
         $this->__hooks['creating'][] = $callback;
-        
+
         return $this;
     }
 
@@ -166,7 +166,7 @@ trait HasEvents
     }
 
     /**
-     * @return  mixed|null
+     * @return mixed|null
      */
     protected function callDeleting()
     {
@@ -174,7 +174,7 @@ trait HasEvents
     }
 
     /**
-     * @return  mixed|null
+     * @return mixed|null
      */
     protected function callDeleted()
     {
@@ -183,6 +183,7 @@ trait HasEvents
 
     /**
      * @param string $name
+     *
      * @return RedirectResponse|\Illuminate\Http\Response|void
      */
     protected function callListeners($name)
@@ -195,10 +196,10 @@ trait HasEvents
             $ret = $func($this);
 
             if (
-                $response ||
-                ! $ret ||
-                ! $ret instanceof Response ||
-                ($ret instanceof RedirectResponse && $this->isAjaxRequest())
+                $response
+                || !$ret
+                || !$ret instanceof Response
+                || ($ret instanceof RedirectResponse && $this->isAjaxRequest())
             ) {
                 continue;
             }

+ 14 - 17
src/Form/Concerns/HasFieldValidator.php

@@ -49,7 +49,7 @@ trait HasFieldValidator
      * Set the update validation rules for the field.
      *
      * @param array|callable|string $rules
-     * @param array $messages
+     * @param array                 $messages
      *
      * @return $this
      */
@@ -66,7 +66,7 @@ trait HasFieldValidator
      * Set the creation validation rules for the field.
      *
      * @param array|callable|string $rules
-     * @param array $messages
+     * @param array                 $messages
      *
      * @return $this
      */
@@ -82,7 +82,7 @@ trait HasFieldValidator
     /**
      * Get or set rules.
      *
-     * @param null $rules
+     * @param null  $rules
      * @param array $messages
      *
      * @return $this
@@ -133,7 +133,7 @@ trait HasFieldValidator
             return $rules;
         }
 
-        if (method_exists($this->form, 'getKey') || ! $id = $this->form->getKey()) {
+        if (method_exists($this->form, 'getKey') || !$id = $this->form->getKey()) {
             return $rules;
         }
 
@@ -164,10 +164,9 @@ trait HasFieldValidator
         return array_filter((array) $rules);
     }
 
-
     /**
      * @param string|array|\Closure $input
-     * @param string|array         $original
+     * @param string|array          $original
      *
      * @return array|\Closure
      */
@@ -175,7 +174,6 @@ trait HasFieldValidator
     {
         if ($input instanceof \Closure) {
             $rules = $input;
-
         } else {
             if (!empty($original)) {
                 $original = $this->formatRules($original);
@@ -227,6 +225,7 @@ trait HasFieldValidator
     /**
      * @param $rules
      * @param $rule
+     *
      * @return void
      */
     protected function deleteRuleByKeyword(&$rules, $rule)
@@ -279,6 +278,7 @@ trait HasFieldValidator
     /**
      * @param $rules
      * @param $rule
+     *
      * @return bool
      */
     protected function isRuleExists($rules, $rule)
@@ -293,7 +293,7 @@ trait HasFieldValidator
 
         $pattern = "/{$rule}[^\|]?(\||$)/";
 
-        return (bool)preg_match($pattern, $rules);
+        return (bool) preg_match($pattern, $rules);
     }
 
     /**
@@ -345,21 +345,20 @@ trait HasFieldValidator
                 if (!array_key_exists($column, $input)) {
                     continue;
                 }
-                $input[$column . $key] = Arr::get($input, $column);
-                $rules[$column . $key] = $fieldRules;
-                $attributes[$column . $key] = $this->label . "[$column]";
+                $input[$column.$key] = Arr::get($input, $column);
+                $rules[$column.$key] = $fieldRules;
+                $attributes[$column.$key] = "{$this->label}[$column]";
             }
         }
 
         return Validator::make($input, $rules, $this->getValidationMessages(), $attributes);
     }
 
-
     /**
      * Set validation messages for column.
      *
      * @param string $key
-     * @param array $messages
+     * @param array  $messages
      *
      * @return $this
      */
@@ -395,7 +394,7 @@ trait HasFieldValidator
             }
 
             if (is_string($this->column)) {
-                $k = $this->column . '.' . $k;
+                $k = $this->column.'.'.$k;
 
                 $result[$k] = $v;
                 continue;
@@ -409,7 +408,6 @@ trait HasFieldValidator
         return $result;
     }
 
-
     /**
      * Set error messages for individual form field.
      *
@@ -417,6 +415,7 @@ trait HasFieldValidator
      *
      * @param string $error
      * @param string $key
+     *
      * @return $this
      */
     public function setClientValidationError(string $error, string $key = null)
@@ -425,6 +424,4 @@ trait HasFieldValidator
 
         return $this->attribute("data-{$key}error", $error);
     }
-
-
 }

+ 11 - 8
src/Form/Concerns/HasFiles.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Form\Concerns;
 
 use Dcat\Admin\Form\Builder;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
 use Dcat\Admin\Form\Field;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 /**
  * @property Builder $builder
@@ -17,8 +17,9 @@ trait HasFiles
     protected function handleUploadFile($data)
     {
         $column = $data['upload_column'] ?? null;
-        $file   = $data['file'] ?? null;
-        if (! $column && ! $file instanceof UploadedFile) {
+        $file = $data['file'] ?? null;
+
+        if (!$column && !$file instanceof UploadedFile) {
             return;
         }
 
@@ -27,11 +28,11 @@ trait HasFiles
         if ($field && $field instanceof Field\File) {
             return $field->upload($file);
         }
-
     }
 
     /**
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse|void
      */
     protected function handleFileDeleteBeforeCreate(array $data)
@@ -41,7 +42,8 @@ trait HasFiles
         }
 
         $column = $data['_column'] ?? null;
-        $file   = $data['key'] ?? null;
+        $file = $data['key'] ?? null;
+
         if (!$column && !$file) {
             return;
         }
@@ -57,6 +59,7 @@ trait HasFiles
 
     /**
      * @param array $input
+     *
      * @return void
      */
     public function deleteFilesWhenCreating(array $input)
@@ -103,14 +106,14 @@ trait HasFiles
      */
     protected function handleFileDelete(array $input = [])
     {
-        if (! array_key_exists(Field::FILE_DELETE_FLAG, $input)) {
+        if (!array_key_exists(Field::FILE_DELETE_FLAG, $input)) {
             return $input;
         }
 
         $input[Field::FILE_DELETE_FLAG] = $input['key'];
         unset($input['key']);
 
-        if (! empty($input['_column'])) {
+        if (!empty($input['_column'])) {
             $input[$input['_column']] = '';
 
             unset($input['_column']);
@@ -123,6 +126,7 @@ trait HasFiles
 
     /**
      * @param array $input
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     protected function handleFileDeleteWhenCreating(array $input)
@@ -143,5 +147,4 @@ trait HasFiles
             return \response()->json(['status' => true]);
         }
     }
-
 }

+ 7 - 3
src/Form/Concerns/HasSteps.php

@@ -13,6 +13,7 @@ trait HasSteps
 {
     /**
      * @param Closure|null $builder
+     *
      * @return StepBuilder
      */
     public function step(\Closure $builder = null)
@@ -22,6 +23,7 @@ trait HasSteps
 
     /**
      * @param array $data
+     *
      * @return void
      */
     protected function prepareStepFormFields(array $data)
@@ -31,7 +33,7 @@ trait HasSteps
         if (
             empty($stepBuilder)
             || empty($stepBuilder->count())
-            || (! isset($data[StepBuilder::ALL_STEPS]) && ! $this->isStepFormValidationRequest())
+            || (!isset($data[StepBuilder::ALL_STEPS]) && !$this->isStepFormValidationRequest())
         ) {
             return;
         }
@@ -51,7 +53,7 @@ trait HasSteps
             return;
         }
 
-        if (! empty($data[StepBuilder::ALL_STEPS])) {
+        if (!empty($data[StepBuilder::ALL_STEPS])) {
             foreach ($steps as $stepForm) {
                 foreach ($stepForm->fields() as $field) {
                     $this->pushField($field);
@@ -74,6 +76,7 @@ trait HasSteps
      * Validate step form.
      *
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
      */
     protected function validateStepForm(array $data)
@@ -94,7 +97,7 @@ trait HasSteps
      */
     protected function responseDoneStep()
     {
-        if (! $builder = $this->builder->getStepBuilder()) {
+        if (!$builder = $this->builder->getStepBuilder()) {
             return;
         }
 
@@ -107,6 +110,7 @@ trait HasSteps
 
     /**
      * @param array $input
+     *
      * @return void
      */
     protected function deleteFileInStepFormStashData($input = [])

+ 3 - 4
src/Form/Condition.php

@@ -28,7 +28,7 @@ class Condition
     public function __construct($condition, Form $form)
     {
         $this->condition = $condition;
-        $this->form      = $form;
+        $this->form = $form;
     }
 
     public function then(\Closure $closure)
@@ -48,7 +48,7 @@ class Condition
         $self = $this;
 
         $condition = $this->form->if(function () use ($self) {
-            return ! $self->getResult();
+            return !$self->getResult();
         });
 
         if ($next) {
@@ -65,7 +65,7 @@ class Condition
         }
         $this->done = true;
 
-        if (! $this->is()) {
+        if (!$this->is()) {
             return;
         }
 
@@ -107,5 +107,4 @@ class Condition
             return $form->$name(...$arguments);
         });
     }
-
 }

+ 6 - 4
src/Form/DoneStep.php

@@ -37,8 +37,8 @@ class DoneStep
 
     public function __construct(Form $form, $title, \Closure $callback)
     {
-        $this->form      = $form;
-        $this->builder   = $callback;
+        $this->form = $form;
+        $this->builder = $callback;
         $this->elementId = 'done-step-'.Str::random();
 
         $this->title($title);
@@ -54,6 +54,7 @@ class DoneStep
 
     /**
      * @param string $title
+     *
      * @return $this|string
      */
     public function title($title = null)
@@ -69,6 +70,7 @@ class DoneStep
 
     /**
      * @param string|\Closure|Renderable $contents
+     *
      * @return $this
      */
     public function content($contents)
@@ -96,7 +98,8 @@ class DoneStep
 
     /**
      * @param string|null $key
-     * @param mixed|null $default
+     * @param mixed|null  $default
+     *
      * @return array|mixed
      */
     public function input($key = null, $default = null)
@@ -131,5 +134,4 @@ class DoneStep
     {
         return Helper::render($this->contents);
     }
-
 }

+ 49 - 47
src/Form/EmbeddedForm.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Form;
 
-use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Collection;
@@ -10,52 +9,55 @@ use Illuminate\Support\Collection;
 /**
  * Class EmbeddedForm.
  *
- * @method Field\Text           text($column, $label = '')
- * @method Field\Checkbox       checkbox($column, $label = '')
- * @method Field\Radio          radio($column, $label = '')
- * @method Field\Select         select($column, $label = '')
- * @method Field\MultipleSelect multipleSelect($column, $label = '')
- * @method Field\Textarea       textarea($column, $label = '')
- * @method Field\Hidden         hidden($column, $label = '')
- * @method Field\Id             id($column, $label = '')
- * @method Field\Ip             ip($column, $label = '')
- * @method Field\Url            url($column, $label = '')
- * @method Field\Color          color($column, $label = '')
- * @method Field\Email          email($column, $label = '')
- * @method Field\Mobile         mobile($column, $label = '')
- * @method Field\Slider         slider($column, $label = '')
- * @method Field\Map            map($latitude, $longitude, $label = '')
- * @method Field\Editor         editor($column, $label = '')
- * @method Field\Date           date($column, $label = '')
- * @method Field\Datetime       datetime($column, $label = '')
- * @method Field\Time           time($column, $label = '')
- * @method Field\Year           year($column, $label = '')
- * @method Field\Month          month($column, $label = '')
- * @method Field\DateRange      dateRange($start, $end, $label = '')
- * @method Field\DateTimeRange  datetimeRange($start, $end, $label = '')
- * @method Field\TimeRange      timeRange($start, $end, $label = '')
- * @method Field\Number         number($column, $label = '')
- * @method Field\Currency       currency($column, $label = '')
- * @method Field\HasMany        hasMany($relationName, $callback)
- * @method Field\SwitchField    switch($column, $label = '')
- * @method Field\Display        display($column, $label = '')
- * @method Field\Rate           rate($column, $label = '')
- * @method Field\Divide         divider()
- * @method Field\Password       password($column, $label = '')
- * @method Field\Decimal        decimal($column, $label = '')
- * @method Field\Html           html($html, $label = '')
- * @method Field\Tags           tags($column, $label = '')
- * @method Field\Icon           icon($column, $label = '')
- * @method Field\Embeds         embeds($column, $label = '')
- * @method Field\Captcha        captcha($column, $label = '')
- * @method Field\Listbox        listbox($column, $label = '')
- * @method Field\SelectResource selectResource($column, $label = '')
- * @method Field\File           file($column, $label = '')
- * @method Field\Image          image($column, $label = '')
- * @method Field\MultipleFile   multipleFile($column, $label = '')
- * @method Field\MultipleImage  multipleImage($column, $label = '')
- * @method Field\Tree           tree($column, $label = '')
- *
+ * @method Field\Text                   text($column, $label = '')
+ * @method Field\Checkbox               checkbox($column, $label = '')
+ * @method Field\Radio                  radio($column, $label = '')
+ * @method Field\Select                 select($column, $label = '')
+ * @method Field\MultipleSelect         multipleSelect($column, $label = '')
+ * @method Field\Textarea               textarea($column, $label = '')
+ * @method Field\Hidden                 hidden($column, $label = '')
+ * @method Field\Id                     id($column, $label = '')
+ * @method Field\Ip                     ip($column, $label = '')
+ * @method Field\Url                    url($column, $label = '')
+ * @method Field\Color                  color($column, $label = '')
+ * @method Field\Email                  email($column, $label = '')
+ * @method Field\Mobile                 mobile($column, $label = '')
+ * @method Field\Slider                 slider($column, $label = '')
+ * @method Field\Map                    map($latitude, $longitude, $label = '')
+ * @method Field\Editor                 editor($column, $label = '')
+ * @method Field\Date                   date($column, $label = '')
+ * @method Field\Datetime               datetime($column, $label = '')
+ * @method Field\Time                   time($column, $label = '')
+ * @method Field\Year                   year($column, $label = '')
+ * @method Field\Month                  month($column, $label = '')
+ * @method Field\DateRange              dateRange($start, $end, $label = '')
+ * @method Field\DateTimeRange          datetimeRange($start, $end, $label = '')
+ * @method Field\TimeRange              timeRange($start, $end, $label = '')
+ * @method Field\Number                 number($column, $label = '')
+ * @method Field\Currency               currency($column, $label = '')
+ * @method Field\SwitchField            switch($column, $label = '')
+ * @method Field\Display                display($column, $label = '')
+ * @method Field\Rate                   rate($column, $label = '')
+ * @method Field\Divide                 divider()
+ * @method Field\Password               password($column, $label = '')
+ * @method Field\Decimal                decimal($column, $label = '')
+ * @method Field\Html                   html($html, $label = '')
+ * @method Field\Tags                   tags($column, $label = '')
+ * @method Field\Icon                   icon($column, $label = '')
+ * @method Field\Embeds                 embeds($column, $label = '')
+ * @method Field\Captcha                captcha()
+ * @method Field\Listbox                listbox($column, $label = '')
+ * @method Field\SelectResource         selectResource($column, $label = '')
+ * @method Field\File                   file($column, $label = '')
+ * @method Field\Image                  image($column, $label = '')
+ * @method Field\MultipleFile           multipleFile($column, $label = '')
+ * @method Field\MultipleImage          multipleImage($column, $label = '')
+ * @method Field\Tree                   tree($column, $label = '')
+ * @method Field\Table                  table($column, $labelOrCallback, $callback = null)
+ * @method Field\ListField              list($column, $label = '')
+ * @method Field\Timezone               timezone($column, $label = '')
+ * @method Field\KeyValue               keyValue($column, $label = '')
+ * @method Field\Tel                    tel($column, $label = '')
  * @method Field\BootstrapFile          bootstrapFile($column, $label = '')
  * @method Field\BootstrapImage         bootstrapImage($column, $label = '')
  * @method Field\BootstrapMultipleImage bootstrapMultipleImage($column, $label = '')

+ 19 - 15
src/Form/Field.php

@@ -5,7 +5,6 @@ namespace Dcat\Admin\Form;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Dcat\Admin\Widgets\Form as WidgetForm;
-use Dcat\Admin\Form\Concerns;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Arr;
@@ -18,7 +17,7 @@ use Illuminate\Support\Traits\Macroable;
  */
 class Field implements Renderable
 {
-    use Macroable, Concerns\HasFieldValidator;
+    use Macroable, Form\Concerns\HasFieldValidator;
 
     const FILE_DELETE_FLAG = '_file_del_';
 
@@ -211,14 +210,14 @@ class Field implements Renderable
     /**
      * Field constructor.
      *
-     * @param       $column
-     * @param array $arguments
+     * @param string|array $column
+     * @param array        $arguments
      */
     public function __construct($column, $arguments = [])
     {
         $this->column = $column;
-        $this->label  = $this->formatLabel($arguments);
-        $this->id     = $this->formatId($column);
+        $this->label = $this->formatLabel($arguments);
+        $this->id = $this->formatId($column);
     }
 
     /**
@@ -343,6 +342,7 @@ class Field implements Renderable
      * Format field data.
      *
      * @param array $data
+     *
      * @return mixed
      */
     protected function formatFieldData($data)
@@ -378,6 +378,7 @@ class Field implements Renderable
      * Set original value to the field.
      *
      * @param array $data
+     *
      * @return void
      */
     final public function setOriginal($data)
@@ -388,7 +389,7 @@ class Field implements Renderable
     }
 
     /**
-     * @param string $key
+     * @param string      $key
      * @param Fluent|null $dataremoveField
      */
     protected function callCustomFormatter($key = 'value', Fluent $data = null)
@@ -421,7 +422,7 @@ class Field implements Renderable
      */
     public function getFormModel()
     {
-        return $this->form ? $this->form->model() : new Fluent;
+        return $this->form ? $this->form->model() : new Fluent();
     }
 
     /**
@@ -473,7 +474,7 @@ class Field implements Renderable
             $checked = $checked->toArray();
         }
 
-        $this->checked = array_merge($this->checked, (array)$checked);
+        $this->checked = array_merge($this->checked, (array) $checked);
 
         return $this;
     }
@@ -525,12 +526,12 @@ class Field implements Renderable
      *
      * @param array $data
      *
-     * @return $this
+     * @return $this|Fluent
      */
     public function data(array $data = null)
     {
         if (is_null($data)) {
-            return $this->data ?: ($this->data = new Fluent);
+            return $this->data ?: ($this->data = new Fluent());
         }
 
         $this->data = new Fluent($data);
@@ -595,6 +596,7 @@ class Field implements Renderable
      * Get or set label of the field.
      *
      * @param null $label
+     *
      * @return $this|string
      */
     public function label($label = null)
@@ -757,6 +759,7 @@ class Field implements Renderable
      * Prepare for a field value before update or insert.
      *
      * @param mixed $value
+     *
      * @return mixed
      */
     protected function prepareToSave($value)
@@ -766,6 +769,7 @@ class Field implements Renderable
 
     /**
      * @param \Closure $closure
+     *
      * @return $this
      */
     public function saving(\Closure $closure)
@@ -779,6 +783,7 @@ class Field implements Renderable
      * Prepare for a field value before update or insert.
      *
      * @param mixed $value
+     *
      * @return mixed
      */
     final public function prepare($value)
@@ -904,13 +909,13 @@ class Field implements Renderable
             $classes = [];
 
             foreach ($elementClass as $index => $class) {
-                $classes[$index] = $formId . ' .'.(is_array($class) ? implode('.', $class) : $class);
+                $classes[$index] = $formId.' .'.(is_array($class) ? implode('.', $class) : $class);
             }
 
             return $classes;
         }
 
-        return $formId . ' .'.implode('.', $elementClass);
+        return $formId.' .'.implode('.', $elementClass);
     }
 
     /**
@@ -1002,7 +1007,7 @@ class Field implements Renderable
 
     /**
      * @param array|string $labelClass
-     * @param bool $append
+     * @param bool         $append
      * @return $this
      */
     public function setLabelClass($labelClass, bool $append = true)
@@ -1121,7 +1126,6 @@ class Field implements Renderable
         static::$css && Admin::css(static::$css);
     }
 
-
     /**
      * Render this filed.
      *

+ 0 - 1
src/Form/Field/BootstrapImage.php

@@ -80,7 +80,6 @@ class BootstrapImage extends BootstrapFile
         return $this->uploadAndDeleteOriginal($image);
     }
 
-
     /**
      * Render a image form field.
      *

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

@@ -140,7 +140,7 @@ class BootstrapMultipleFile extends Field
             return explode(',', $value);
         }
 
-        return $value ? (array)$value : [];
+        return $value ? (array) $value : [];
     }
 
     /**

+ 0 - 1
src/Form/Field/BootstrapMultipleImage.php

@@ -38,7 +38,6 @@ class BootstrapMultipleImage extends BootstrapMultipleFile
         });
     }
 
-
     /**
      * Render a image form field.
      *

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

@@ -15,7 +15,7 @@ class Captcha extends Text
         }
 
         $this->column = '__captcha__';
-        $this->label  = trans('admin.captcha');
+        $this->label = trans('admin.captcha');
     }
 
     public function setForm($form = null)
@@ -31,7 +31,7 @@ class Captcha extends Text
 
     public function render()
     {
-        $this->script = <<<JS
+        $this->script = <<<'JS'
 $('.field-refresh-captcha').off('click').click(function () {
     $(this).attr('src', $(this).attr('data-url')+'?'+Math.random());
 });

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

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Form\Field;
 
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Arrayable;
 
 class Checkbox extends MultipleSelect
 {
@@ -44,7 +43,7 @@ class Checkbox extends MultipleSelect
     }
 
     /**
-     * "info", "primary", "inverse", "danger", "success", "purple"
+     * "info", "primary", "inverse", "danger", "success", "purple".
      *
      * @param $v
      * @return $this
@@ -97,7 +96,9 @@ class Checkbox extends MultipleSelect
     public function value($value = null)
     {
         if (is_null($value)) {
-            if ($this->value === null) return $this->getDefault();
+            if ($this->value === null) {
+                return $this->getDefault();
+            }
 
             if (count($this->value) === 0) {
                 return $this->getDefault();

+ 0 - 1
src/Form/Field/Currency.php

@@ -74,5 +74,4 @@ class Currency extends Text
     {
         Admin::collectComponentAssets('jquery.inputmask');
     }
-
 }

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

@@ -43,5 +43,4 @@ class Date extends Text
         Admin::collectComponentAssets('moment');
         Admin::collectComponentAssets('bootstrap-datetimepicker');
     }
-
 }

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

@@ -73,7 +73,7 @@ JS;
         $result = [];
         foreach ($messages as $key => $message) {
             $column = explode('.', $key);
-            $rule   = array_pop($column);
+            $rule = array_pop($column);
             $column = join('.', $column);
 
             if ($this->column['start'] == $column) {

+ 5 - 7
src/Form/Field/File.php

@@ -7,7 +7,6 @@ use Dcat\Admin\Support\Helper;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Str;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 class File extends Field
 {
@@ -137,9 +136,9 @@ class File extends Field
 
         foreach ($this->value() as $value) {
             $previews[] = [
-                'id' => $value,
+                'id'   => $value,
                 'path' => basename($value),
-                'url' => $this->objectUrl($value)
+                'url'  => $this->objectUrl($value),
             ];
         }
 
@@ -160,7 +159,7 @@ class File extends Field
     {
         $this->setDefaultServer();
 
-        if (! empty($this->value())) {
+        if (!empty($this->value())) {
             $this->setupPreviewOptions();
         }
 
@@ -183,9 +182,9 @@ class File extends Field
     protected function formatValue()
     {
         if ($this->value !== null) {
-            $this->value = join(',', $this->value);
+            $this->value = implode(',', $this->value);
         } elseif (is_array($this->default)) {
-            $this->default = join(',', $this->default);
+            $this->default = implode(',', $this->default);
         }
     }
 
@@ -196,5 +195,4 @@ class File extends Field
     {
         return 'file-'.Str::random(8);
     }
-
 }

+ 2 - 4
src/Form/Field/HasMany.php

@@ -6,8 +6,6 @@ use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Form\NestedForm;
-use Illuminate\Database\Eloquent\Relations\HasMany as Relation;
-use Illuminate\Database\Eloquent\Relations\MorphMany;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Str;
@@ -670,8 +668,8 @@ JS;
     protected function renderTable()
     {
         $headers = [];
-        $fields  = [];
-        $hidden  = [];
+        $fields = [];
+        $hidden = [];
         $scripts = [];
 
         /* @var Field $field */

+ 16 - 14
src/Form/Field/Image.php

@@ -2,8 +2,6 @@
 
 namespace Dcat\Admin\Form\Field;
 
-use Dcat\Admin\Form\Field;
-use Illuminate\Support\Facades\Validator;
 use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 /**
@@ -74,20 +72,23 @@ class Image extends File
 
     /**
      * @param array $options support:
-     *     [
-     *         'width' => 100,
-     *         'height' => 100,
-     *         'min_width' => 100,
-     *         'min_height' => 100,
-     *         'max_width' => 100,
-     *         'max_height' => 100,
-     *         'ratio' => 3/2, // (width / height)
-     *     ]
+     *                       [
+     *                       'width' => 100,
+     *                       'height' => 100,
+     *                       'min_width' => 100,
+     *                       'min_height' => 100,
+     *                       'max_width' => 100,
+     *                       'max_height' => 100,
+     *                       'ratio' => 3/2, // (width / height)
+     *                       ]
+     *
      * @return $this
      */
     public function dimensions(array $options)
     {
-        if (!$options) return $this;
+        if (!$options) {
+            return $this;
+        }
 
         $this->options(['dimensions' => $options]);
 
@@ -95,13 +96,14 @@ class Image extends File
             $v = "$k=$v";
         }
 
-        return $this->rules('dimensions:'.join(',', $options));
+        return $this->rules('dimensions:'.implode(',', $options));
     }
 
     /**
      * Set ratio constraint.
      *
      * @param float $ratio width/height
+     *
      * @return $this
      */
     public function ratio($ratio)
@@ -109,6 +111,7 @@ class Image extends File
         if ($ratio <= 0) {
             return $this;
         }
+
         return $this->dimensions(['ratio' => $ratio]);
     }
 
@@ -134,5 +137,4 @@ class Image extends File
 
         $this->destroyThumbnail();
     }
-
 }

+ 7 - 7
src/Form/Field/ImageField.php

@@ -3,10 +3,10 @@
 namespace Dcat\Admin\Form\Field;
 
 use Illuminate\Support\Str;
-use Intervention\Image\ImageManagerStatic;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
 use Intervention\Image\Constraint;
 use Intervention\Image\Facades\Image as InterventionImage;
+use Intervention\Image\ImageManagerStatic;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 trait ImageField
 {
@@ -25,7 +25,7 @@ trait ImageField
     protected $thumbnails = [];
 
     protected static $interventionAlias = [
-        'filling' => 'fill'
+        'filling' => 'fill',
     ];
 
     /**
@@ -117,18 +117,18 @@ trait ImageField
      * Destroy original thumbnail files.
      *
      * @param string|array $file
-     * @param bool $force
+     * @param bool         $force
      *
      * @return void.
      */
     public function destroyThumbnail($file = null, bool $force = false)
     {
-        if ($this->retainable && ! $force) {
+        if ($this->retainable && !$force) {
             return;
         }
 
         $file = $file ?: $this->original;
-        if (! $file) {
+        if (!$file) {
             return;
         }
 
@@ -136,6 +136,7 @@ trait ImageField
             foreach ($file as $f) {
                 $this->destroyThumbnail($f);
             }
+
             return;
         }
 
@@ -194,5 +195,4 @@ trait ImageField
 
         return $this;
     }
-
 }

+ 2 - 0
src/Form/Field/ListField.php

@@ -39,6 +39,7 @@ class ListField extends Field
     public function max(int $size)
     {
         $this->max = $size;
+
         return $this;
     }
 
@@ -52,6 +53,7 @@ class ListField extends Field
     public function min(int $size)
     {
         $this->min = $size;
+
         return $this;
     }
 

+ 2 - 4
src/Form/Field/MultipleFile.php

@@ -2,11 +2,7 @@
 
 namespace Dcat\Admin\Form\Field;
 
-use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Support\Arr;
-use Illuminate\Support\Facades\Validator;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 class MultipleFile extends File
 {
@@ -16,6 +12,7 @@ class MultipleFile extends File
      * Set a limit of files.
      *
      * @param int $limit
+     *
      * @return $this
      */
     public function limit(int $limit)
@@ -32,6 +29,7 @@ class MultipleFile extends File
      * Prepare for saving.
      *
      * @param string|array $file
+     *
      * @return array
      */
     protected function prepareToSave($file)