jqh 6 年 前
コミット
aa86ecf199

+ 0 - 1
src/Form.php

@@ -758,7 +758,6 @@ class Form implements Renderable
 
             return $this->ajaxResponse(__('admin.update_succeeded'));
         }
-
     }
 
     /**

+ 1 - 1
src/Form/Builder.php

@@ -154,7 +154,6 @@ class Builder
         $this->footer = new Footer($this);
     }
 
-
     /**
      * @param \Closure $closure
      *
@@ -824,6 +823,7 @@ EOF;
 
     /**
      * @param Renderable $view
+     *
      * @return string
      */
     protected function doWrap(Renderable $view)

+ 1 - 0
src/Form/Concerns/HasSteps.php

@@ -50,6 +50,7 @@ trait HasSteps
             foreach ($steps[$currentIndex]->fields() as $field) {
                 $this->pushField($field);
             }
+
             return;
         }
 

+ 1 - 0
src/Form/Field.php

@@ -1008,6 +1008,7 @@ class Field implements Renderable
     /**
      * @param array|string $labelClass
      * @param bool         $append
+     *
      * @return $this
      */
     public function setLabelClass($labelClass, bool $append = true)

+ 2 - 1
src/Form/Field/Checkbox.php

@@ -45,7 +45,8 @@ class Checkbox extends MultipleSelect
     /**
      * "info", "primary", "inverse", "danger", "success", "purple".
      *
-     * @param $v
+     * @param string $v
+     *
      * @return $this
      */
     public function style($v)

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

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

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

@@ -315,6 +315,7 @@ class HasMany extends Field
                 })
                 ->map(function ($item) {
                     unset($item[NestedForm::REMOVE_FLAG_NAME]);
+
                     return $item;
                 })
                 ->toArray()

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

@@ -117,7 +117,6 @@ class Image extends File
 
     /**
      * @param UploadedFile $file
-     *
      */
     protected function prepareFile(UploadedFile $file)
     {

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

@@ -2,10 +2,7 @@
 
 namespace Dcat\Admin\Form\Field;
 
-use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Support\Facades\Validator;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 class MultipleImage extends Image
 {
@@ -15,6 +12,7 @@ class MultipleImage extends Image
      * Set a limit of files.
      *
      * @param int $limit
+     *
      * @return $this
      */
     public function limit(int $limit)
@@ -22,6 +20,7 @@ class MultipleImage extends Image
         if ($limit < 2) {
             return $this;
         }
+
         $this->options['fileNumLimit'] = $limit;
 
         return $this;
@@ -31,6 +30,7 @@ class MultipleImage extends Image
      * Prepare for saving.
      *
      * @param string|array $file
+     *
      * @return array
      */
     protected function prepareToSave($file)

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

@@ -21,7 +21,6 @@ $('{$this->getElementClassSelector()}:not(.initialized)')
         downClass: 'primary',
         center: true
     });
-
 JS;
 
         $this->prepend('')->defaultAttribute('style', 'width: 200px');
@@ -31,7 +30,7 @@ JS;
 
     protected function prepareToSave($value)
     {
-        return (int)$value;
+        return (int) $value;
     }
 
     /**

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

@@ -4,7 +4,6 @@ namespace Dcat\Admin\Form\Field;
 
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Arrayable;
 
 class Radio extends Field
 {
@@ -57,9 +56,10 @@ class Radio extends Field
     }
 
     /**
-     * "info", "primary", "inverse", "danger", "success", "purple"
+     * "info", "primary", "inverse", "danger", "success", "purple".
+     *
+     * @param string $v
      *
-     * @param $v
      * @return $this
      */
     public function style($v)
@@ -93,8 +93,8 @@ class Radio extends Field
         }
 
         $this->addVariables([
-            'options' => $this->options,
-            'inline' => $this->inline,
+            'options'    => $this->options,
+            'inline'     => $this->inline,
             'radioStyle' => $this->style,
         ]);
 

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

@@ -5,7 +5,6 @@ namespace Dcat\Admin\Form\Field;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Str;

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

@@ -5,8 +5,8 @@ namespace Dcat\Admin\Form\Field;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Arrayable;
 use Dcat\Admin\Widgets\Color;
+use Illuminate\Contracts\Support\Arrayable;
 
 class SelectResource extends Field
 {
@@ -29,6 +29,7 @@ class SelectResource extends Field
      *
      * @param string $width
      * @param string $height
+     *
      * @return $this
      */
     public function area(string $width, string $height)
@@ -42,6 +43,7 @@ class SelectResource extends Field
      * Set button style.
      *
      * @param string $style
+     *
      * @return $this
      */
     public function style(string $style = 'primary')
@@ -78,13 +80,13 @@ class SelectResource extends Field
         }
 
         $this->options = Helper::array($this->options);
-
     }
 
     /**
      * Multiple select.
      *
      * @param int|null|null $max
+     *
      * @return SelectResource
      */
     public function multiple(?int $max = null)
@@ -93,8 +95,8 @@ class SelectResource extends Field
     }
 
     /**
-     *
      * @param ?int $max
+     *
      * @return $this
      */
     public function max(?int $max)
@@ -132,7 +134,7 @@ class SelectResource extends Field
             }
         }
 
-        $this->value = json_encode((object)$this->value);
+        $this->value = json_encode((object) $this->value);
     }
 
     protected function setDefaultSource()
@@ -152,6 +154,7 @@ class SelectResource extends Field
             if ($value === null || $value === '') {
                 return 0;
             }
+
             return $value;
         }
 
@@ -183,16 +186,15 @@ class SelectResource extends Field
             ->defaultAttribute('name', $name);
 
         $this->addVariables([
-            'className'   => str_replace(['[', ']'], '_', $name),
-            'prepend'     => $this->prepend,
-            'append'      => $this->append,
-            'area'        => json_encode($this->area),
-            'maxItem'     => $this->maxItem,
-            'source'      => $this->source,
-            'placeholder' => $this->getPlaceholder(),
-            'style'       => $this->style,
-            'disabled'    => empty($this->attributes['disabled']) ? '' : 'disabled',
-
+            'className'        => str_replace(['[', ']'], '_', $name),
+            'prepend'          => $this->prepend,
+            'append'           => $this->append,
+            'area'             => json_encode($this->area),
+            'maxItem'          => $this->maxItem,
+            'source'           => $this->source,
+            'placeholder'      => $this->getPlaceholder(),
+            'style'            => $this->style,
+            'disabled'         => empty($this->attributes['disabled']) ? '' : 'disabled',
             'inputContainerId' => $this->id.$this->getFormId(),
         ]);
 

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

@@ -43,11 +43,11 @@ class SwitchField extends Field
         return $this->color(Color::blue());
     }
 
-
     /**
      * Set color of the switcher.
      *
-     * @param $color
+     * @param string $color
+     *
      * @return $this
      */
     public function color($color)
@@ -57,7 +57,8 @@ class SwitchField extends Field
 
     /**
      *
-     * @param $color
+     * @param string $color
+     *
      * @return $this
      */
     public function secondary($color)
@@ -83,6 +84,7 @@ class SwitchField extends Field
 
     /**
      * @param mixed $value
+     *
      * @return int
      */
     protected function prepareToSave($value)

+ 10 - 5
src/Form/Field/Table.php

@@ -16,19 +16,18 @@ class Table extends HasMany
      * Table constructor.
      *
      * @param string $column
-     * @param array $arguments
+     * @param array  $arguments
      */
     public function __construct($column, $arguments = [])
     {
         $this->column = $column;
+
         if (count($arguments) == 1) {
             $this->label = $this->formatLabel();
             $this->builder = $arguments[0];
-        }
-        if (count($arguments) == 2) {
+        } elseif (count($arguments) == 2) {
             list($this->label, $this->builder) = $arguments;
         }
-
     }
 
     /**
@@ -39,12 +38,15 @@ class Table extends HasMany
         if (is_null($this->form)) {
             return [];
         }
+
         $forms = [];
+
         if ($values = old($this->column)) {
             foreach ($values as $key => $data) {
                 if ($data[NestedForm::REMOVE_FLAG_NAME] == 1) {
                     continue;
                 }
+
                 $forms[$key] = $this->buildNestedForm($this->column, $this->builder, $key)->fill($data);
             }
         } else {
@@ -52,9 +54,11 @@ class Table extends HasMany
                 if (isset($data['pivot'])) {
                     $data = array_merge($data, $data['pivot']);
                 }
+
                 $forms[$key] = $this->buildNestedForm($this->column, $this->builder, $key)->fill($data);
             }
         }
+
         return $forms;
     }
 
@@ -68,6 +72,7 @@ class Table extends HasMany
                 return $item[NestedForm::REMOVE_FLAG_NAME] == 1;
             })->map(function ($item) {
                 unset($item[NestedForm::REMOVE_FLAG_NAME]);
+
                 return $item;
             })->toArray()
         );
@@ -78,6 +83,7 @@ class Table extends HasMany
         if (is_null($this->form)) {
             return;
         }
+
         return 'id';
     }
 
@@ -107,5 +113,4 @@ CSS
 
         return $this->renderTable();
     }
-
 }

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

@@ -38,6 +38,7 @@ class Text extends Field
      * Set input type.
      *
      * @param string $type
+     *
      * @return $this
      */
     public function type(string $type)
@@ -51,13 +52,14 @@ class Text extends Field
      * @see http://1000hz.github.io/bootstrap-validator/
      *
      * @param string|Field $field
-     * @param string $error
+     * @param string       $error
+     *
      * @return $this
      */
     public function same($field, ?string $error = null)
     {
         $field = $field instanceof Field ? $field : $this->form->field($field);
-        $name  = $field->column();
+        $name = $field->column();
 
         if ($name.'_confirmation' === $this->column) {
             $field->rules('confirmed');
@@ -67,14 +69,14 @@ class Text extends Field
 
         $attributes = [
             'data-match'       => '#'.$field->getElementId(),
-            'data-match-error' => str_replace([':attribute', ':other'], [$this->label, $name], $error ?: trans('admin.validation.match'))
+            'data-match-error' => str_replace([':attribute', ':other'], [$this->label, $name], $error ?: trans('admin.validation.match')),
         ];
 
         return $this->attribute($attributes);
     }
 
     /**
-     * @param int $length
+     * @param int         $length
      * @param string|null $error
      * @return $this
      */
@@ -93,8 +95,9 @@ class Text extends Field
     }
 
     /**
-     * @param int $length
+     * @param int         $length
      * @param string|null $error
+     *
      * @return $this
      */
     public function maxLength(int $length, ?string $error = null)

+ 26 - 17
src/Form/Field/Tree.php

@@ -13,11 +13,11 @@ class Tree extends Field
 {
     protected $options = [
         'plugins' => ['checkbox', 'types'],
-        'core' => [
+        'core'    => [
             'check_callback' => true,
 
             'themes' => [
-                'name' => 'proton',
+                'name'       => 'proton',
                 'responsive' => true,
             ],
         ],
@@ -25,7 +25,7 @@ class Tree extends Field
             'keep_selected_style' => false,
         ],
         'types' => [
-            'default' => [
+            'default'  => [
                 'icon' => false,
             ],
         ],
@@ -67,12 +67,12 @@ class Tree extends Field
 
     /**
      * @param array|Arrayable|\Closure $data exp:
-     *     {
-     *          "id": "1",
-     *          "parent": "#",
-     *          "text": "Dashboard",
-     *          // "state": {"selected": true}
-     *     }
+     *                                       {
+     *                                       "id": "1",
+     *                                       "parent": "#",
+     *                                       "text": "Dashboard",
+     *                                       // "state": {"selected": true}
+     *                                       }
      *
      * @return $this
      */
@@ -81,6 +81,7 @@ class Tree extends Field
         if ($data instanceof Arrayable) {
             $data = $data->toArray();
         }
+
         $this->nodes = &$data;
 
         return $this;
@@ -112,12 +113,13 @@ class Tree extends Field
      * @param string $idColumn
      * @param string $textColumn
      * @param string $parentColumn
+     *
      * @return $this
      */
     public function columnNames(string $idColumn = 'id', string $textColumn = 'name', string $parentColumn = 'parent_id')
     {
-        $this->columnNames['id']     = $idColumn;
-        $this->columnNames['text']   = $textColumn;
+        $this->columnNames['id'] = $idColumn;
+        $this->columnNames['text'] = $textColumn;
         $this->columnNames['parent'] = $parentColumn;
 
         return $this;
@@ -135,16 +137,20 @@ class Tree extends Field
             $this->nodes = $this->nodes->call($this->getFormModel(), $this->value(), $this);
         }
 
-        if (!$this->nodes) return;
+        if (!$this->nodes) {
+            return;
+        }
 
-        $idColumn     = $this->columnNames['id'];
-        $textColumn   = $this->columnNames['text'];
+        $idColumn = $this->columnNames['id'];
+        $textColumn = $this->columnNames['text'];
         $parentColumn = $this->columnNames['parent'];
 
         $parentIds = $nodes = [];
 
         foreach ($this->nodes as &$v) {
-            if (empty($v[$idColumn])) continue;
+            if (empty($v[$idColumn])) {
+                continue;
+            }
 
             $parentId = $v[$parentColumn] ?? '#';
             if (empty($parentId)) {
@@ -183,6 +189,7 @@ class Tree extends Field
      * Set type.
      *
      * @param array $value
+     *
      * @return $this
      */
     public function type(array $value)
@@ -196,6 +203,7 @@ class Tree extends Field
      * Set plugins.
      *
      * @param array $value
+     *
      * @return $this
      */
     public function plugins(array $value)
@@ -228,6 +236,7 @@ class Tree extends Field
      * Prepare for saving.
      *
      * @param string|array $value
+     *
      * @return array
      */
     protected function prepareToSave($value)
@@ -246,7 +255,7 @@ class Tree extends Field
         $checkboxes->circle(false);
         $checkboxes->options([
             1 => trans('admin.selectall'),
-            2 => trans('admin.expand')
+            2 => trans('admin.expand'),
         ]);
         if ($this->readOnly) {
             $checkboxes->disabled(1);
@@ -257,7 +266,7 @@ class Tree extends Field
         $this->formatNodes();
 
         if ($v = $this->value()) {
-            $this->attribute('value', join(',', $v));
+            $this->attribute('value', implode(',', $v));
         }
 
         $this->addVariables([

+ 3 - 1
src/Form/Field/UploadField.php

@@ -460,6 +460,7 @@ trait UploadField
 
     /**
      * @param UploadedFile $file
+     *
      * @return bool|\Illuminate\Support\MessageBag
      */
     protected function getErrorMessages(UploadedFile $file)
@@ -479,7 +480,7 @@ trait UploadField
         if (!$validator->passes()) {
             $errors = $validator->errors()->getMessages()[$this->column];
 
-            return join('; ', $errors);
+            return implode('; ', $errors);
         }
     }
 
@@ -493,6 +494,7 @@ trait UploadField
         if ($this->retainable) {
             return;
         }
+
         $this->deleteFile($this->original);
     }
 

+ 6 - 4
src/Grid/Displayers/SwitchGroup.php

@@ -31,21 +31,23 @@ class SwitchGroup extends SwitchDisplay
         foreach ($columns as $column => $label) {
             $html[] = $this->buildSwitch($column, $label);
         }
-        return '<table>' . join('', $html) . '</table>';
+
+        return '<table>'.implode('', $html).'</table>';
     }
 
     protected function buildSwitch($name, $label = '')
     {
         $class = 'grid-switch-group-'.$this->grid->getName();
-        $keys  = collect(explode('.', $name));
+        $keys = collect(explode('.', $name));
 
         if ($keys->isEmpty()) {
             $elementName = $name;
         } else {
             $elementName = $keys->shift() . $keys->reduce(function ($carry, $val) {
-                    return "{$carry}[{$val}]";
-                });
+                return "{$carry}[{$val}]";
+            });
         }
+
         $script = <<<JS
 (function () {
     var swt = $('.$class'), t;

+ 3 - 5
src/Grid/Displayers/Tree.php

@@ -150,12 +150,11 @@ class Tree extends AbstractDisplayer
         return <<<EOF
 <a href="javascript:void(0)" class="{$this->getSelectorPrefix()}-open-tree" data-checked="{$this->checkedAll}" data-val="{$val}"><i class='ti-layout-list-post'></i> $btn</a>
 EOF;
-
     }
 
     protected function format($val)
     {
-        return join(',', Helper::array($val, true));
+        return implode(',', Helper::array($val, true));
     }
 
     protected function getSelectorPrefix()
@@ -167,8 +166,8 @@ EOF;
     {
         $title = $this->title ?: $this->column->getLabel();
 
-        $area  = json_encode($this->area);
-        $opts  = json_encode($this->options);
+        $area = json_encode($this->area);
+        $opts = json_encode($this->options);
         $nodes = json_encode($this->nodes);
 
         Admin::script(
@@ -262,7 +261,6 @@ $('.{$this->getSelectorPrefix()}-open-tree').click(function () {
     
 });
 JS
-
         );
     }
 

+ 1 - 1
src/Models/Permission.php

@@ -121,7 +121,7 @@ class Permission extends Model
      */
     public function setHttpPathAttribute($path)
     {
-        if (is_array($path)) $path = join(',', $path);
+        if (is_array($path)) $path = implode(',', $path);
 
         return $this->attributes['http_path'] = $path;
     }

+ 1 - 1
src/Support/helpers.php

@@ -170,7 +170,7 @@ if (!function_exists('admin_trans')) {
         ) {
             unset($arr[0]);
             array_unshift($arr, 'global');
-            $key = join('.', $arr);
+            $key = implode('.', $arr);
 
             if (!$translator->has($key)) {
                 return end($arr);

+ 2 - 2
src/Traits/HasAssets.php

@@ -339,7 +339,7 @@ trait HasAssets
             return;
         }
 
-        $script = join(';', array_unique(self::$script));
+        $script = implode(';', array_unique(self::$script));
 
         return "<script data-exec-on-popstate>LA.ready(function () { {$script} });</script>";
 
@@ -358,7 +358,7 @@ trait HasAssets
             return;
         }
 
-        $style = join('', array_unique(self::$style));
+        $style = implode('', array_unique(self::$style));
 
         return "<style>$style</style>";
     }

+ 2 - 2
src/Widgets/AjaxRequestBuilder.php

@@ -149,8 +149,8 @@ trait AjaxRequestBuilder
 
         $this->fn = 'frd_'.Str::random(8);
 
-        $fetching = join(';', $this->javascripts['fetching']);
-        $fetched  = join(';', $this->javascripts['fetched']);
+        $fetching = implode(';', $this->javascripts['fetching']);
+        $fetched  = implode(';', $this->javascripts['fetched']);
 
         $binding = '';
         foreach ($this->buttonSelectors as $v) {