Browse Source

Merge pull request #3 from jqhph/analysis-RvxOwp

Apply fixes from StyleCI
Jiang Qinghua 6 years ago
parent
commit
eb3a6b21cb
100 changed files with 492 additions and 348 deletions
  1. 0 1
      src/Form/Field/UploadField.php
  2. 1 1
      src/Form/Field/WebUploader.php
  3. 1 1
      src/Form/Footer.php
  4. 1 1
      src/Form/Layout.php
  5. 5 5
      src/Form/StepBuilder.php
  6. 1 1
      src/Grid/Column.php
  7. 3 3
      src/Grid/Column/HasDisplayers.php
  8. 1 1
      src/Grid/Column/HasHeader.php
  9. 2 3
      src/Grid/Concerns/HasExporter.php
  10. 1 1
      src/Grid/Concerns/HasMultipleHeader.php
  11. 1 1
      src/Grid/Concerns/HasQuickSearch.php
  12. 0 1
      src/Grid/Concerns/HasTools.php
  13. 1 0
      src/Grid/Displayers/QRCode.php
  14. 0 1
      src/Grid/Displayers/Tree.php
  15. 0 1
      src/Grid/Exporters/AbstractExporter.php
  16. 0 1
      src/Grid/Filter.php
  17. 1 1
      src/Grid/Header.php
  18. 1 1
      src/Grid/Tools/CreateButton.php
  19. 3 3
      src/Grid/Tools/Selector.php
  20. 9 4
      src/Layout/Content.php
  21. 9 3
      src/Layout/Menu.php
  22. 30 24
      src/Layout/SectionManager.php
  23. 0 2
      src/Middleware/Authenticate.php
  24. 0 2
      src/Middleware/Bootstrap.php
  25. 1 2
      src/Middleware/LogOperation.php
  26. 1 1
      src/Middleware/Permission.php
  27. 0 1
      src/Middleware/Pjax.php
  28. 5 5
      src/Models/AdminTablesSeeder.php
  29. 1 2
      src/Models/HasPermissions.php
  30. 1 3
      src/Models/Menu.php
  31. 3 2
      src/Models/MenuCache.php
  32. 2 0
      src/Models/Permission.php
  33. 1 2
      src/Models/Repositories/Administrator.php
  34. 6 5
      src/Models/Repositories/Extension.php
  35. 1 1
      src/Models/Repositories/OperationLog.php
  36. 3 1
      src/Models/Role.php
  37. 15 5
      src/Repositories/EloquentRepository.php
  38. 1 1
      src/Repositories/Proxy.php
  39. 4 6
      src/Repositories/Repository.php
  40. 6 6
      src/Repositories/RepositoryListener.php
  41. 2 2
      src/Scaffold/ControllerCreator.php
  42. 7 6
      src/Scaffold/FormCreator.php
  43. 6 6
      src/Scaffold/GridCreator.php
  44. 6 4
      src/Scaffold/LangCreator.php
  45. 1 1
      src/Scaffold/MigrationCreator.php
  46. 2 2
      src/Scaffold/ModelCreator.php
  47. 3 2
      src/Scaffold/RepositoryCreator.php
  48. 6 5
      src/Scaffold/ShowCreator.php
  49. 10 3
      src/Show.php
  50. 14 6
      src/Show/Field.php
  51. 1 2
      src/Show/Panel.php
  52. 5 6
      src/Show/Relation.php
  53. 4 4
      src/Show/Tools.php
  54. 4 4
      src/Support/Composer.php
  55. 4 1
      src/Support/ComposerProperty.php
  56. 32 23
      src/Support/Helper.php
  57. 1 1
      src/Support/StringOutput.php
  58. 21 13
      src/Support/helpers.php
  59. 10 13
      src/Traits/HasAssets.php
  60. 4 4
      src/Traits/HasBuilderEvents.php
  61. 1 0
      src/Traits/HasDefinitions.php
  62. 7 2
      src/Traits/HasHtmlAttributes.php
  63. 1 1
      src/Traits/ModelTree.php
  64. 7 5
      src/Tree.php
  65. 1 3
      src/Tree/Tools.php
  66. 10 3
      src/Widgets/AjaxRequestBuilder.php
  67. 4 1
      src/Widgets/Alert.php
  68. 2 1
      src/Widgets/Box.php
  69. 2 1
      src/Widgets/Card.php
  70. 2 0
      src/Widgets/Chart/Bar.php
  71. 25 7
      src/Widgets/Chart/Chart.php
  72. 0 3
      src/Widgets/Chart/Doughnut.php
  73. 2 4
      src/Widgets/Chart/Pie.php
  74. 0 3
      src/Widgets/Chart/PolarArea.php
  75. 0 3
      src/Widgets/Chart/Radar.php
  76. 8 3
      src/Widgets/Chart/ScaleSetting.php
  77. 3 2
      src/Widgets/Checkbox.php
  78. 11 8
      src/Widgets/Code.php
  79. 1 1
      src/Widgets/Color.php
  80. 13 6
      src/Widgets/DataCard/Card.php
  81. 3 2
      src/Widgets/DataCard/DoughnutChartCard.php
  82. 1 0
      src/Widgets/DataCard/LineChartCard.php
  83. 13 4
      src/Widgets/Dropdown.php
  84. 4 1
      src/Widgets/Dump.php
  85. 9 4
      src/Widgets/Form.php
  86. 11 9
      src/Widgets/Markdown.php
  87. 21 13
      src/Widgets/ModalForm.php
  88. 1 1
      src/Widgets/NavList.php
  89. 2 3
      src/Widgets/Navbar.php
  90. 6 3
      src/Widgets/Radio.php
  91. 0 3
      src/Widgets/Sparkline/Bar.php
  92. 12 5
      src/Widgets/Sparkline/Sparkline.php
  93. 1 0
      src/Widgets/Tab.php
  94. 3 2
      src/Widgets/Table.php
  95. 3 2
      src/Widgets/Terminal.php
  96. 6 0
      src/Widgets/Tooltip.php
  97. 17 16
      src/Widgets/Tree.php
  98. 11 6
      src/Widgets/Widget.php
  99. 2 2
      tests/Controllers/DropdownController.php
  100. 1 1
      tests/Controllers/ReportController.php

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

@@ -348,7 +348,6 @@ trait UploadField
     }
 
     /**
-     *
      * @param array $message
      *
      * @return \Illuminate\Http\JsonResponse

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

@@ -18,7 +18,7 @@ trait WebUploader
 
     /**
      * @param string      $extensions exp. gif,jpg,jpeg,bmp,png
-     * @param string|null $mimeTypes exp. image/*
+     * @param string|null $mimeTypes  exp. image/*
      *
      * @return $this
      */

+ 1 - 1
src/Form/Footer.php

@@ -147,7 +147,7 @@ class Footer implements Renderable
         }
 
         if (in_array('view', $this->checkboxes)) {
-            $options[3] =  sprintf('<span class="text-80 text-bold">%s</span>', trans('admin.view'));
+            $options[3] = sprintf('<span class="text-80 text-bold">%s</span>', trans('admin.view'));
         }
 
         if (!$options) {

+ 1 - 1
src/Form/Layout.php

@@ -23,7 +23,7 @@ class Layout
     }
 
     /**
-     * @param int   $width 1~12
+     * @param int   $width   1~12
      * @param mixed $content
      */
     public function column(int $width, $content)

+ 5 - 5
src/Form/StepBuilder.php

@@ -177,7 +177,7 @@ class StepBuilder
     {
         if ($title instanceof Closure) {
             $callback = $title;
-            $title    = trans('admin.done');
+            $title = trans('admin.done');
         }
 
         $this->doneStep = new DoneStep($this->form, $title, $callback);
@@ -190,7 +190,7 @@ class StepBuilder
      */
     public function getDoneStep()
     {
-        if (! $this->doneStep) {
+        if (!$this->doneStep) {
             $this->setDefaultDonePage();
         }
 
@@ -288,15 +288,15 @@ class StepBuilder
      */
     public function stashIndexByField($field)
     {
-        if (! $this->options['remember']) {
+        if (!$this->options['remember']) {
             return;
         }
 
         $data = $this->fetchStash();
 
-        $data[StepBuilder::CURRENT_VALIDATION_STEP] = ($this->getFieldIndex($field) ?: 0) - 1;
+        $data[self::CURRENT_VALIDATION_STEP] = ($this->getFieldIndex($field) ?: 0) - 1;
 
-        unset($data[StepBuilder::ALL_STEPS]);
+        unset($data[self::ALL_STEPS]);
 
         $this->stash($data);
     }

+ 1 - 1
src/Grid/Column.php

@@ -454,7 +454,7 @@ class Column
      * Set help message for column.
      *
      * @param string|\Closure $help
-     * @param null|string     $style 'green', 'blue', 'red', 'purple'
+     * @param null|string     $style     'green', 'blue', 'red', 'purple'
      * @param null|string     $placement 'bottom', 'left', 'right', 'top'
      *
      * @return $this

+ 3 - 3
src/Grid/Column/HasDisplayers.php

@@ -144,7 +144,7 @@ trait HasDisplayers
     }
 
     /**
-     * Split a string by string
+     * Split a string by string.
      *
      * @param string $d
      *
@@ -184,8 +184,8 @@ trait HasDisplayers
     /**
      * Limit the number of characters in a string.
      *
-     * @param  int    $limit
-     * @param  string $end
+     * @param int    $limit
+     * @param string $end
      *
      * @return $this
      */

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

@@ -62,7 +62,7 @@ trait HasHeader
      * Add a help tooltip to column header.
      *
      * @param string|\Closure $message
-     * @param null|string     $style 'green', 'blue', 'red', 'purple'
+     * @param null|string     $style     'green', 'blue', 'red', 'purple'
      * @param null|string     $placement 'bottom', 'left', 'right', 'top'
      *
      * @return $this

+ 2 - 3
src/Grid/Concerns/HasExporter.php

@@ -53,7 +53,7 @@ trait HasExporter
      */
     protected function handleExportRequest($forceExport = false)
     {
-        if (! $scope = request($this->getExporter()->getQueryName())) {
+        if (!$scope = request($this->getExporter()->getQueryName())) {
             return;
         }
 
@@ -107,7 +107,6 @@ trait HasExporter
         return $this->exportDriver->withScope($scope);
     }
 
-
     /**
      * Get the export url.
      *
@@ -137,7 +136,7 @@ trait HasExporter
         if (!$this->allowExporter()) {
             return '';
         }
-        
+
         return (new Tools\ExportButton($this))->render();
     }
 

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

@@ -81,7 +81,7 @@ trait HasMultipleHeader
         }
 
         $beforeHeaders = $this->createHeaderWithColumns($before);
-        $afterHeaders  = $this->createHeaderWithColumns($after);
+        $afterHeaders = $this->createHeaderWithColumns($after);
 
         $this->columnNames = array_merge(
             array_keys($before),

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

@@ -223,7 +223,7 @@ trait HasQuickSearch
      * Add where date time function binding to model query.
      *
      * @param string $column
-     * @param bool $or
+     * @param bool   $or
      * @param string $function
      * @param string $value
      */

+ 0 - 1
src/Grid/Concerns/HasTools.php

@@ -170,7 +170,6 @@ trait HasTools
         return $this->disableRefreshButton(!$val);
     }
 
-
     /**
      * If grid show toolbar.
      *

+ 1 - 0
src/Grid/Displayers/QRCode.php

@@ -33,6 +33,7 @@ JS;
         }
 
         $img = "<img src='https://api.qrserver.com/v1/create-qr-code/?size={$width}x{$height}&data={$content}' style='height: {$width}px;width: {$height}px;'/>";
+
         return <<<HTML
 <a href="javascript:void(0);" class="grid-column-qrcode text-muted" data-content="{$img}" data-toggle='popover' tabindex='0'>
     <i class="fa fa-qrcode"></i>

+ 0 - 1
src/Grid/Displayers/Tree.php

@@ -55,7 +55,6 @@ class Tree extends AbstractDisplayer
      *                    "text": "Dashboard",
      *                    // "state": {"selected": true}
      *                    }
-     *
      * @param array $data
      *
      * @return $this

+ 0 - 1
src/Grid/Exporters/AbstractExporter.php

@@ -172,7 +172,6 @@ abstract class AbstractExporter implements ExporterInterface
     }
 
     /**
-     *
      * @return string
      */
     public function getFilename()

+ 0 - 1
src/Grid/Filter.php

@@ -599,7 +599,6 @@ class Filter implements Renderable
     }
 
     /**
-     *
      * @param string $style
      *
      * @return $this

+ 1 - 1
src/Grid/Header.php

@@ -99,7 +99,7 @@ class Header extends Widget
      * Add a help tooltip to column header.
      *
      * @param string|\Closure $message
-     * @param null|string     $style 'green', 'blue', 'red', 'purple'
+     * @param null|string     $style     'green', 'blue', 'red', 'purple'
      * @param null|string     $placement 'bottom', 'left', 'right', 'top'
      *
      * @return $this

+ 1 - 1
src/Grid/Tools/CreateButton.php

@@ -55,7 +55,7 @@ class CreateButton
 
     public function render()
     {
-        if (!$this->grid->option('show_create_btn') && ! $this->grid->option('show_quick_create_btn')) {
+        if (!$this->grid->option('show_create_btn') && !$this->grid->option('show_quick_create_btn')) {
             return;
         }
 

+ 3 - 3
src/Grid/Tools/Selector.php

@@ -116,12 +116,12 @@ class Selector
      */
     public function parseSelected()
     {
-        if (! is_null($this->selected)) {
+        if (!is_null($this->selected)) {
             return $this->selected;
         }
 
         $selected = $this->request->get($this->queryName, []);
-        if (! is_array($selected)) {
+        if (!is_array($selected)) {
             return [];
         }
 
@@ -166,7 +166,7 @@ class Selector
             array_push($options, $value);
         }
 
-        if (! empty($options)) {
+        if (!empty($options)) {
             Arr::set($query, "{$this->queryName}.{$column}", implode(',', $options));
         } else {
             Arr::forget($query, "{$this->queryName}.{$column}");

+ 9 - 4
src/Layout/Content.php

@@ -6,7 +6,6 @@ use Closure;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Arr;
 
 class Content implements Renderable
 {
@@ -61,6 +60,7 @@ class Content implements Renderable
      * Create a content instance.
      *
      * @param mixed ...$params
+     *
      * @return $this
      */
     public static function make(...$params)
@@ -144,8 +144,10 @@ class Content implements Renderable
 
     /**
      * @param array $breadcrumb
-     * @return void
+     *
      * @throws \Exception
+     *
+     * @return void
      */
     protected function formatBreadcrumb(array &$breadcrumb)
     {
@@ -172,7 +174,7 @@ class Content implements Renderable
                     'text' => $breadcrumb[0] ?? null,
                     'url'  => $breadcrumb[1] ?? null,
                     'icon' => $breadcrumb[2] ?? null,
-                ]
+                ],
             ];
         }
     }
@@ -193,6 +195,7 @@ class Content implements Renderable
      * Add one row for content body.
      *
      * @param $content
+     *
      * @return $this
      */
     public function row($content)
@@ -210,6 +213,7 @@ class Content implements Renderable
 
     /**
      * @param $content
+     *
      * @return $this
      */
     public function prepend($content)
@@ -324,6 +328,7 @@ class Content implements Renderable
      * Set content view.
      *
      * @param null|string $view
+     *
      * @return $this
      */
     public function setView(?string $view)
@@ -340,7 +345,7 @@ class Content implements Renderable
     {
         if (
             $this->view !== 'admin::contents.simple'
-            && in_array('fixed', (array)config('admin.layout'))
+            && in_array('fixed', (array) config('admin.layout'))
         ) {
             Admin::style(
                 <<<'CSS'

+ 9 - 3
src/Layout/Menu.php

@@ -69,7 +69,7 @@ class Menu
 
     /**
      * @param array $nodes
-     * @param int $priority
+     * @param int   $priority
      */
     public function add(array $nodes = [], int $priority = 10)
     {
@@ -82,8 +82,10 @@ class Menu
      * Build html.
      *
      * @param array $nodes
-     * @return string
+     *
      * @throws \Throwable
+     *
+     * @return string
      */
     public function build(array $nodes)
     {
@@ -97,6 +99,7 @@ class Menu
 
     /**
      * @param array $item
+     *
      * @return array|string
      */
     protected function renderMenu(array $item)
@@ -105,8 +108,9 @@ class Menu
     }
 
     /**
-     * @param array $item
+     * @param array       $item
      * @param null|string $path
+     *
      * @return bool
      */
     public function isActive(array $item, ?string $path = null)
@@ -119,6 +123,7 @@ class Menu
             if (empty($item['uri'])) {
                 return false;
             }
+
             return trim($this->getPath($item['uri']), '/') == $path;
         }
 
@@ -138,6 +143,7 @@ class Menu
 
     /**
      * @param array $menuItem
+     *
      * @return bool
      */
     public function show(array $menuItem)

+ 30 - 24
src/Layout/SectionManager.php

@@ -3,11 +3,9 @@
 namespace Dcat\Admin\Layout;
 
 use Dcat\Admin\Support\Helper;
-use Illuminate\Support\Fluent;
-use InvalidArgumentException;
-use Illuminate\Contracts\View\View;
-use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Contracts\Support\Htmlable;
+use Illuminate\Contracts\Support\Renderable;
+use Illuminate\Support\Fluent;
 
 class SectionManager
 {
@@ -26,10 +24,11 @@ class SectionManager
     /**
      * Inject content into a section.
      *
-     * @param  string  $section
+     * @param string                              $section
      * @param string|Renderable|Htmlable|callable $content
-     * @param bool $append
-     * @param int $priority
+     * @param bool                                $append
+     * @param int                                 $priority
+     *
      * @return void
      */
     public function inject($section, $content, bool $append = true, int $priority = 10)
@@ -38,8 +37,9 @@ class SectionManager
     }
 
     /**
-     * @param  string  $section
+     * @param string                              $section
      * @param string|Renderable|Htmlable|callable $content
+     *
      * @return void
      */
     public function injectDefault($section, $content)
@@ -51,35 +51,35 @@ class SectionManager
         $this->defaultSections[$section] = &$content;
     }
 
-
     /**
      * Set content to a given section.
      *
-     * @param string  $section
+     * @param string                              $section
      * @param string|Renderable|Htmlable|callable $content
-     * @param bool $append
-     * @param int $priority
+     * @param bool                                $append
+     * @param int                                 $priority
+     *
      * @return void
      */
     protected function put($section, $content, bool $append = false, int $priority = 10)
     {
-        if (! $section) {
-            throw new \InvalidArgumentException("Section name is required.");
+        if (!$section) {
+            throw new \InvalidArgumentException('Section name is required.');
         }
 
-        if (! isset($this->sections[$section])) {
+        if (!isset($this->sections[$section])) {
             unset($this->defaultSections[$section]);
 
             $this->sections[$section] = [];
         }
 
-        if (! isset($this->sections[$section][$priority])) {
+        if (!isset($this->sections[$section][$priority])) {
             $this->sections[$section][$priority] = [];
         }
 
         $this->sections[$section][$priority][] = [
             'append' => $append,
-            'value' => &$content,
+            'value'  => &$content,
         ];
     }
 
@@ -88,14 +88,15 @@ class SectionManager
      *
      * @param $section
      * @param string $default
-     * @param array $options
+     * @param array  $options
+     *
      * @return string
      */
     public function yieldContent($section, $default = '', array $options = [])
     {
         $defaultSection = $this->defaultSections[$section] ?? null;
 
-        if (! $this->hasSection($section) && $defaultSection === null) {
+        if (!$this->hasSection($section) && $defaultSection === null) {
             return Helper::render($default, [new Fluent()]);
         }
 
@@ -107,7 +108,8 @@ class SectionManager
     /**
      * Get all of the sections for a given name.
      *
-     * @param  string  $name
+     * @param string $name
+     *
      * @return array
      */
     public function getSections($name)
@@ -118,7 +120,8 @@ class SectionManager
     /**
      * Sort the listeners for a given event by priority.
      *
-     * @param  string  $name
+     * @param string $name
+     *
      * @return array
      */
     protected function sortSections($name)
@@ -137,7 +140,8 @@ class SectionManager
     /**
      * Check if section exists.
      *
-     * @param  string  $name
+     * @param string $name
+     *
      * @return bool
      */
     public function hasSection($name)
@@ -148,7 +152,8 @@ class SectionManager
     /**
      * Check if default section exists.
      *
-     * @param  string  $name
+     * @param string $name
+     *
      * @return bool
      */
     public function hasDefaultSection($name)
@@ -160,6 +165,7 @@ class SectionManager
      * @param $name
      * @param $content
      * @param array $options
+     *
      * @return string
      */
     protected function resolveContent($name, &$content, array &$options)
@@ -178,7 +184,7 @@ class SectionManager
 
         $result = '';
         foreach ($content as &$item) {
-            $value  = Helper::render($item['value'] ?? '', [$options]);
+            $value = Helper::render($item['value'] ?? '', [$options]);
             $append = $item['append'] ?? false;
 
             if (!$append) {

+ 0 - 2
src/Middleware/Authenticate.php

@@ -6,8 +6,6 @@ use Closure;
 use Dcat\Admin\Admin;
 use Dcat\Admin\Support\Helper;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\URL;
 
 class Authenticate
 {

+ 0 - 2
src/Middleware/Bootstrap.php

@@ -3,8 +3,6 @@
 namespace Dcat\Admin\Middleware;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Form;
-use Dcat\Admin\Grid;
 use Illuminate\Http\Request;
 
 class Bootstrap

+ 1 - 2
src/Middleware/LogOperation.php

@@ -2,11 +2,10 @@
 
 namespace Dcat\Admin\Middleware;
 
-use Dcat\Admin\Models\OperationLog as OperationLogModel;
 use Dcat\Admin\Admin;
+use Dcat\Admin\Models\OperationLog as OperationLogModel;
 use Dcat\Admin\Support\Helper;
 use Illuminate\Http\Request;
-use Illuminate\Support\Str;
 
 class LogOperation
 {

+ 1 - 1
src/Middleware/Permission.php

@@ -2,8 +2,8 @@
 
 namespace Dcat\Admin\Middleware;
 
-use Dcat\Admin\Auth\Permission as Checker;
 use Dcat\Admin\Admin;
+use Dcat\Admin\Auth\Permission as Checker;
 use Dcat\Admin\Support\Helper;
 use Illuminate\Http\Request;
 use Illuminate\Support\Str;

+ 0 - 1
src/Middleware/Pjax.php

@@ -5,7 +5,6 @@ namespace Dcat\Admin\Middleware;
 use Closure;
 use Dcat\Admin\Admin;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\MessageBag;
 use Symfony\Component\DomCrawler\Crawler;
 use Symfony\Component\HttpFoundation\Response;

+ 5 - 5
src/Models/AdminTablesSeeder.php

@@ -52,7 +52,7 @@ class AdminTablesSeeder extends Seeder
                 'name'        => 'Users',
                 'slug'        => 'users',
                 'http_method' => '',
-                'http_path'   => "/auth/users*",
+                'http_path'   => '/auth/users*',
                 'parent_id'   => 1,
                 'created_at'  => $createdAt,
             ],
@@ -61,7 +61,7 @@ class AdminTablesSeeder extends Seeder
                 'name'        => 'Roles',
                 'slug'        => 'roles',
                 'http_method' => '',
-                'http_path'   => "/auth/roles*",
+                'http_path'   => '/auth/roles*',
                 'parent_id'   => 1,
                 'created_at'  => $createdAt,
             ],
@@ -70,7 +70,7 @@ class AdminTablesSeeder extends Seeder
                 'name'        => 'Permissions',
                 'slug'        => 'permissions',
                 'http_method' => '',
-                'http_path'   => "/auth/permissions*",
+                'http_path'   => '/auth/permissions*',
                 'parent_id'   => 1,
                 'created_at'  => $createdAt,
             ],
@@ -79,7 +79,7 @@ class AdminTablesSeeder extends Seeder
                 'name'        => 'Menu',
                 'slug'        => 'menu',
                 'http_method' => '',
-                'http_path'   => "/auth/menu*",
+                'http_path'   => '/auth/menu*',
                 'parent_id'   => 1,
                 'created_at'  => $createdAt,
             ],
@@ -88,7 +88,7 @@ class AdminTablesSeeder extends Seeder
                 'name'        => 'Operation log',
                 'slug'        => 'operation-log',
                 'http_method' => '',
-                'http_path'   => "/auth/logs*",
+                'http_path'   => '/auth/logs*',
                 'parent_id'   => 1,
                 'created_at'  => $createdAt,
             ],

+ 1 - 2
src/Models/HasPermissions.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Models;
 
-use Dcat\Admin\Support\Helper;
 use Illuminate\Support\Collection;
 
 trait HasPermissions
@@ -100,7 +99,7 @@ trait HasPermissions
     {
         $all = $this->roles;
 
-        $roles = (array)$roles;
+        $roles = (array) $roles;
 
         return $all->pluck('slug')->intersect($roles)->isNotEmpty() ?:
             $all->pluck('id')->intersect($roles)->isNotEmpty();

+ 1 - 3
src/Models/Menu.php

@@ -4,9 +4,7 @@ namespace Dcat\Admin\Models;
 
 use Dcat\Admin\Traits\ModelTree;
 use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
-use Illuminate\Database\Eloquent\Relations\HasOne;
 use Illuminate\Support\Facades\DB;
 
 /**
@@ -95,7 +93,7 @@ class Menu extends Model
 
         $byOrder = 'ROOT ASC, '.$orderColumn;
 
-        $self = new static;
+        $self = new static();
         if ($this->queryCallback instanceof \Closure) {
             $self = call_user_func($this->queryCallback, $self);
         }

+ 3 - 2
src/Models/MenuCache.php

@@ -12,6 +12,7 @@ trait MenuCache
      * Get an item from the cache, or execute the given Closure and store the result.
      *
      * @param \Closure $builder
+     *
      * @return mixed
      */
     protected function remember(\Closure $builder)
@@ -31,7 +32,7 @@ trait MenuCache
     public function destroyCache()
     {
         if (!$this->enableCache()) {
-            return null;
+            return;
         }
 
         return $this->getStore()->delete($this->getCacheKey());
@@ -42,7 +43,7 @@ trait MenuCache
      */
     protected function getCacheKey()
     {
-        return sprintf($this->cacheKey, (int)static::withPermission());
+        return sprintf($this->cacheKey, (int) static::withPermission());
     }
 
     /**

+ 2 - 0
src/Models/Permission.php

@@ -98,6 +98,7 @@ class Permission extends Model
      * Get options for Select field in form.
      *
      * @param \Closure|null $closure
+     *
      * @return array
      */
     public static function selectOptions(\Closure $closure = null)
@@ -109,6 +110,7 @@ class Permission extends Model
 
     /**
      * @param string $path
+     *
      * @return mixed
      */
     public function getHttpPathAttribute($path)

+ 1 - 2
src/Models/Repositories/Administrator.php

@@ -4,7 +4,6 @@ namespace Dcat\Admin\Models\Repositories;
 
 use Dcat\Admin\Grid;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Pagination\AbstractPaginator;
 
 class Administrator extends EloquentRepository
@@ -32,7 +31,7 @@ class Administrator extends EloquentRepository
 
         $items = collect($items);
 
-        $roleKeyName = (new $roleModel)->getKeyName();
+        $roleKeyName = (new $roleModel())->getKeyName();
 
         $roleIds = $items
             ->pluck('roles')

+ 6 - 5
src/Models/Repositories/Extension.php

@@ -3,12 +3,12 @@
 namespace Dcat\Admin\Models\Repositories;
 
 use Dcat\Admin\Admin;
+use Dcat\Admin\Extension as AbstractExtension;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Repositories\Repository;
 use Dcat\Admin\Show;
 use Dcat\Admin\Support\Composer;
-use Dcat\Admin\Extension as AbstractExtension;
 
 class Extension extends Repository
 {
@@ -24,13 +24,14 @@ class Extension extends Repository
 
     /**
      * @param AbstractExtension $extension
+     *
      * @return array
      */
     protected function each(AbstractExtension $extension)
     {
         $property = Composer::parse($extension->composerJson());
 
-        $config = (array)config('admin-extensions.'.$extension->getName());
+        $config = (array) config('admin-extensions.'.$extension->getName());
 
         return [
             'id'           => $extension::NAME,
@@ -43,7 +44,7 @@ class Extension extends Repository
             'require_dev'  => $property->require_dev,
             'homepage'     => $property->homepage,
             'enable'       => $extension::enabled(),
-            'config'       => (array)$extension->config(),
+            'config'       => (array) $extension->config(),
             'imported'     => $config['imported'] ?? false,
             'imported_at'  => $config['imported_at'] ?? null,
         ];
@@ -66,7 +67,7 @@ class Extension extends Repository
 
         $attributes = $form->getUpdates();
 
-        $enable = (bool)($attributes['enable'] ?? false);
+        $enable = (bool) ($attributes['enable'] ?? false);
 
         Admin::enableExtenstion($extension, $enable);
 
@@ -77,6 +78,7 @@ class Extension extends Repository
      * Get data before update.
      *
      * @param Form $form
+     *
      * @return array
      */
     public function getDataWhenUpdating(Form $form): array
@@ -84,7 +86,6 @@ class Extension extends Repository
         return [];
     }
 
-
     public function detail(Show $show): array
     {
         return [];

+ 1 - 1
src/Models/Repositories/OperationLog.php

@@ -2,8 +2,8 @@
 
 namespace Dcat\Admin\Models\Repositories;
 
-use Dcat\Admin\Repositories\EloquentRepository;
 use Dcat\Admin\Models\OperationLog as OperationLogModel;
+use Dcat\Admin\Repositories\EloquentRepository;
 
 class OperationLog extends EloquentRepository
 {

+ 3 - 1
src/Models/Role.php

@@ -86,6 +86,7 @@ class Role extends Model
      * Get id of the permission by id.
      *
      * @param array $roleIds
+     *
      * @return \Illuminate\Support\Collection
      */
     public static function getPermissionId(array $roleIds)
@@ -95,7 +96,7 @@ class Role extends Model
         }
         $related = config('admin.database.role_permissions_table');
 
-        $model   = new static;
+        $model = new static();
         $keyName = $model->getKeyName();
 
         return $model->newQuery()
@@ -113,6 +114,7 @@ class Role extends Model
 
     /**
      * @param string $slug
+     *
      * @return bool
      */
     public static function isAdministrator(?string $slug)

+ 15 - 5
src/Repositories/EloquentRepository.php

@@ -7,11 +7,11 @@ use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model as EloquentModel;
+use Illuminate\Database\Eloquent\Relations;
 use Illuminate\Database\Eloquent\SoftDeletes;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\DB;
-use Illuminate\Database\Eloquent\Relations;
 use Illuminate\Support\Str;
 use Spatie\EloquentSortable\Sortable;
 
@@ -89,7 +89,8 @@ abstract class EloquentRepository extends Repository
     /**
      * Set the relationships that should be eager loaded.
      *
-     * @param  mixed  $relations
+     * @param mixed $relations
+     *
      * @return $this
      */
     public function with($relations)
@@ -103,6 +104,7 @@ abstract class EloquentRepository extends Repository
      * Get the grid data.
      *
      * @param Grid\Model $model
+     *
      * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|Collection|array
      */
     public function get(Grid\Model $model)
@@ -130,6 +132,7 @@ abstract class EloquentRepository extends Repository
      * Get data to build edit form.
      *
      * @param Form $form
+     *
      * @return array
      */
     public function edit(Form $form): array
@@ -151,6 +154,7 @@ abstract class EloquentRepository extends Repository
      * Get detail data.
      *
      * @param Show $show
+     *
      * @return array
      */
     public function detail(Show $show): array
@@ -172,6 +176,7 @@ abstract class EloquentRepository extends Repository
      * Store a new record.
      *
      * @param Form $form
+     *
      * @return mixed
      */
     public function store(Form $form)
@@ -205,6 +210,7 @@ abstract class EloquentRepository extends Repository
      * Get data before update.
      *
      * @param Form $form
+     *
      * @return array
      */
     public function getDataWhenUpdating(Form $form): array
@@ -216,6 +222,7 @@ abstract class EloquentRepository extends Repository
      * Update form data.
      *
      * @param Form $form
+     *
      * @return bool
      */
     public function update(Form $form)
@@ -290,6 +297,7 @@ abstract class EloquentRepository extends Repository
      * Destroy data.
      *
      * @param Form $form
+     *
      * @return bool
      */
     public function destroy(Form $form, array $deletingData)
@@ -324,6 +332,7 @@ abstract class EloquentRepository extends Repository
 
     /**
      * @param Form $form
+     *
      * @return array
      */
     public function getDataWhenDeleting(Form $form): array
@@ -348,7 +357,7 @@ abstract class EloquentRepository extends Repository
     }
 
     /**
-     * Get the eloquent model
+     * Get the eloquent model.
      *
      * @return EloquentModel
      */
@@ -359,11 +368,12 @@ abstract class EloquentRepository extends Repository
 
     /**
      * @param array $data
+     *
      * @return EloquentModel
      */
     public function createEloquent(array $data = [])
     {
-        $model = new $this->eloquentClass;
+        $model = new $this->eloquentClass();
 
         if ($data) {
             $model->forceFill($data);
@@ -418,7 +428,7 @@ abstract class EloquentRepository extends Repository
      * Get inputs for relations.
      *
      * @param EloquentModel $model
-     * @param array $inputs
+     * @param array         $inputs
      *
      * @return array
      */

+ 1 - 1
src/Repositories/Proxy.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Repositories;
 
 use Dcat\Admin\Form;
-use Dcat\Admin\Show;
 use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
 
 class Proxy implements \Dcat\Admin\Contracts\Repository
 {

+ 4 - 6
src/Repositories/Repository.php

@@ -62,7 +62,6 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
         return 'updated_at';
     }
 
-
     /**
      * @return bool
      */
@@ -177,7 +176,6 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
     }
 
     /**
-     *
      * @param mixed ...$params
      *
      * @return $this
@@ -200,7 +198,7 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
         $array = $storage->get('repository.listeners') ?: [];
 
         foreach ((array) $repositories as $v) {
-            if (! isset($array[$v])) {
+            if (!isset($array[$v])) {
                 $array[$v] = [];
             }
 
@@ -219,7 +217,7 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
      */
     public static function getListeners(?string $repository)
     {
-        if (! $repository) {
+        if (!$repository) {
             return null;
         }
 
@@ -236,7 +234,7 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
 
         $resolves[$repository] = [];
 
-        if (! isset($listeners[$repository])) {
+        if (!isset($listeners[$repository])) {
             return $any;
         }
 
@@ -244,7 +242,7 @@ abstract class Repository implements \Dcat\Admin\Contracts\Repository
             if (!class_exists($class)) {
                 continue;
             }
-            $listener = new $class;
+            $listener = new $class();
 
             if (!$listener instanceof RepositoryListener) {
                 continue;

+ 6 - 6
src/Repositories/RepositoryListener.php

@@ -18,7 +18,7 @@ abstract class RepositoryListener
     /**
      * Created event.
      *
-     * @param Form $form
+     * @param Form  $form
      * @param mixed $newId
      */
     public function created(Form $form, $newId)
@@ -28,7 +28,7 @@ abstract class RepositoryListener
     /**
      * Updating event.
      *
-     * @param Form $form
+     * @param Form  $form
      * @param array $originalAttributes
      */
     public function updating(Form $form, array $originalAttributes)
@@ -38,9 +38,9 @@ abstract class RepositoryListener
     /**
      * Updated event.
      *
-     * @param Form $form
+     * @param Form  $form
      * @param array $originalAttributes
-     * @param bool $result
+     * @param bool  $result
      */
     public function updated(Form $form, array $originalAttributes, $result)
     {
@@ -49,7 +49,7 @@ abstract class RepositoryListener
     /**
      * Deleting event.
      *
-     * @param Form $form
+     * @param Form  $form
      * @param array $originalAttributes
      */
     public function deleting(Form $form, array $originalAttributes)
@@ -59,7 +59,7 @@ abstract class RepositoryListener
     /**
      * Deleted event.
      *
-     * @param Form $form
+     * @param Form  $form
      * @param array $originalAttributes
      * @param $result
      */

+ 2 - 2
src/Scaffold/ControllerCreator.php

@@ -45,7 +45,7 @@ class ControllerCreator
     public function create($model)
     {
         $path = $this->getpath($this->name);
-        $dir  = dirname($path);
+        $dir = dirname($path);
 
         if (!is_dir($dir)) {
             $this->files->makeDirectory($dir, 0755, true);
@@ -150,6 +150,6 @@ class ControllerCreator
      */
     public function getStub()
     {
-        return __DIR__ . '/stubs/controller.stub';
+        return __DIR__.'/stubs/controller.stub';
     }
 }

+ 7 - 6
src/Scaffold/FormCreator.php

@@ -6,14 +6,15 @@ trait FormCreator
 {
     /**
      * @param string $primaryKey
-     * @param array $fields
-     * @param bool $timestamps
+     * @param array  $fields
+     * @param bool   $timestamps
+     *
      * @return string
      */
     protected function generateForm(string $primaryKey = null, array $fields = [], $timestamps = null)
     {
         $primaryKey = $primaryKey ?: request('primary_key', 'id');
-        $fields     = $fields ?: request('fields', []);
+        $fields = $fields ?: request('fields', []);
         $timestamps = $timestamps === null ? request('timestamps', true) : $timestamps;
 
         $rows = [
@@ -35,10 +36,10 @@ EOF
             $rows[] = "            \$form->text('{$field['name']}');";
         }
         if ($timestamps) {
-            $rows[] = <<<EOF
+            $rows[] = <<<'EOF'
         
-            \$form->display('created_at');
-            \$form->display('updated_at');
+            $form->display('created_at');
+            $form->display('updated_at');
 EOF;
         }
 

+ 6 - 6
src/Scaffold/GridCreator.php

@@ -6,17 +6,18 @@ trait GridCreator
 {
     /**
      * @param string $primaryKey
-     * @param array $fields
+     * @param array  $fields
+     *
      * @return string
      */
     protected function generateGrid(string $primaryKey = null, array $fields = [], $timestamps = null)
     {
         $primaryKey = $primaryKey ?: request('primary_key', 'id');
-        $fields     = $fields ?: request('fields', []);
+        $fields = $fields ?: request('fields', []);
         $timestamps = $timestamps === null ? request('timestamps', true) : $timestamps;
 
         $rows = [
-            "\$grid->{$primaryKey}->bold()->sortable();"
+            "\$grid->{$primaryKey}->bold()->sortable();",
         ];
 
         foreach ($fields as $field) {
@@ -32,8 +33,8 @@ trait GridCreator
         }
 
         if ($timestamps) {
-            $rows[] = "            \$grid->created_at;";
-            $rows[] = "            \$grid->updated_at->sortable();";
+            $rows[] = '            $grid->created_at;';
+            $rows[] = '            $grid->updated_at->sortable();';
         }
 
         $rows[] = <<<EOF
@@ -44,7 +45,6 @@ trait GridCreator
             });
 EOF;
 
-
         return implode("\n", $rows);
     }
 }

+ 6 - 4
src/Scaffold/LangCreator.php

@@ -16,9 +16,10 @@ class LangCreator
     }
 
     /**
-     * 生成语言包
+     * 生成语言包.
      *
      * @param string $controller
+     *
      * @return string
      */
     public function create(string $controller)
@@ -34,7 +35,7 @@ class LangCreator
             'labels' => [
                 $controller => $controller,
             ],
-            'fields' => [],
+            'fields'  => [],
             'options' => [],
         ];
         foreach ($this->fields as $field) {
@@ -51,15 +52,16 @@ class LangCreator
     }
 
     /**
-     * 获取语言包路径
+     * 获取语言包路径.
      *
      * @param string $controller
+     *
      * @return string
      */
     protected function getLangPath(string $controller)
     {
         $path = resource_path('lang/'.App::getLocale());
 
-        return $path . '/' . Str::slug($controller) . '.php';
+        return $path.'/'.Str::slug($controller).'.php';
     }
 }

+ 1 - 1
src/Scaffold/MigrationCreator.php

@@ -28,7 +28,7 @@ class MigrationCreator extends BaseMigrationCreator
 
         $path = $this->getPath($name, $path);
 
-        $stub = $this->files->get(__DIR__ . '/stubs/create.stub');
+        $stub = $this->files->get(__DIR__.'/stubs/create.stub');
 
         $this->files->put($path, $this->populateStub($name, $stub, $table));
 

+ 2 - 2
src/Scaffold/ModelCreator.php

@@ -57,7 +57,7 @@ class ModelCreator
     public function create($keyName = 'id', $timestamps = true, $softDeletes = false)
     {
         $path = $this->getpath($this->name);
-        $dir  = dirname($path);
+        $dir = dirname($path);
 
         if (!is_dir($dir)) {
             $this->files->makeDirectory($dir, 0755, true);
@@ -240,6 +240,6 @@ class ModelCreator
      */
     public function getStub()
     {
-        return __DIR__ . '/stubs/model.stub';
+        return __DIR__.'/stubs/model.stub';
     }
 }

+ 3 - 2
src/Scaffold/RepositoryCreator.php

@@ -9,6 +9,7 @@ class RepositoryCreator
     /**
      * @param string $controllerClass
      * @param string $modelClass
+     *
      * @return string
      */
     public function create(string $controllerClass, string $modelClass)
@@ -44,7 +45,7 @@ class RepositoryCreator
             $baseController,
             $controller,
             $modelClass,
-            $model
+            $model,
         ], $content));
 
         return $path;
@@ -52,6 +53,6 @@ class RepositoryCreator
 
     protected function stub()
     {
-        return __DIR__ . '/stubs/repository.stub';
+        return __DIR__.'/stubs/repository.stub';
     }
 }

+ 6 - 5
src/Scaffold/ShowCreator.php

@@ -6,13 +6,14 @@ trait ShowCreator
 {
     /**
      * @param string $primaryKey
-     * @param array $fields
+     * @param array  $fields
+     *
      * @return string
      */
     protected function generateShow(string $primaryKey = null, array $fields = [], $timestamps = null)
     {
         $primaryKey = $primaryKey ?: request('primary_key', 'id');
-        $fields     = $fields ?: request('fields', []);
+        $fields = $fields ?: request('fields', []);
         $timestamps = $timestamps === null ? request('timestamps', true) : $timestamps;
 
         $rows = [];
@@ -29,13 +30,13 @@ trait ShowCreator
             $rows[] = "            \$show->{$field['name']};";
 
             if ($k === 1 && (count($fields) > 2 || $timestamps)) {
-                $rows[] = "            \$show->divider();";
+                $rows[] = '            $show->divider();';
             }
         }
 
         if ($timestamps) {
-            $rows[] = "            \$show->created_at;";
-            $rows[] = "            \$show->updated_at;";
+            $rows[] = '            $show->created_at;';
+            $rows[] = '            $show->updated_at;';
         }
 
         return trim(implode("\n", $rows));

+ 10 - 3
src/Show.php

@@ -86,7 +86,7 @@ class Show implements Renderable
      * Show constructor.
      *
      * @param Model|Repository|array|Arrayable $model
-     * @param \Closure $builder
+     * @param \Closure                         $builder
      */
     public function __construct($model = null, ?\Closure $builder = null)
     {
@@ -117,6 +117,7 @@ class Show implements Renderable
      * Create a show instance.
      *
      * @param mixed ...$params
+     *
      * @return $this
      */
     public static function make(...$params)
@@ -126,6 +127,7 @@ class Show implements Renderable
 
     /**
      * @param string $value
+     *
      * @return $this
      */
     public function setKeyName(string $value)
@@ -142,7 +144,7 @@ class Show implements Renderable
      */
     public function getKeyName()
     {
-        if (! $this->repository) {
+        if (!$this->repository) {
             return $this->keyName;
         }
 
@@ -178,7 +180,7 @@ class Show implements Renderable
      */
     public function model()
     {
-        if (! $this->model) {
+        if (!$this->model) {
             $this->setupModel();
         }
 
@@ -199,6 +201,7 @@ class Show implements Renderable
      *
      * @param string $view
      * @param array  $variables
+     *
      * @return $this
      */
     public function setView($view, $variables = [])
@@ -216,6 +219,7 @@ class Show implements Renderable
      * Add variables to show view.
      *
      * @param array $variables
+     *
      * @return $this
      */
     public function with($variables = [])
@@ -486,6 +490,7 @@ class Show implements Renderable
      *
      * @param null|string $width
      * @param null|string $height
+     *
      * @return $this
      */
     public function showQuickEdit(?string $width = null, ?string $height = null)
@@ -562,6 +567,7 @@ class Show implements Renderable
     /**
      * @param $method
      * @param array $arguments
+     *
      * @return bool|Show|Field|Relation
      */
     protected function call($method, $arguments = [])
@@ -636,6 +642,7 @@ class Show implements Renderable
      * Add a model field to show.
      *
      * @param string $name
+     *
      * @return Field|Collection
      */
     public function __get($name)

+ 14 - 6
src/Show/Field.php

@@ -117,8 +117,8 @@ class Field implements Renderable
      */
     public function __construct($name = '', $label = '')
     {
-        $this->name   = $name;
-        $this->label  = $this->formatLabel($label);
+        $this->name = $name;
+        $this->label = $this->formatLabel($label);
         $this->showAs = new Collection();
 
         $this->callResolving();
@@ -150,11 +150,13 @@ class Field implements Renderable
 
     /**
      * @param int $width
+     *
      * @return $this
      */
     public function width(int $width)
     {
         $this->width = $width;
+
         return $this;
     }
 
@@ -380,6 +382,7 @@ HTML;
 
     /**
      * @param string $val
+     *
      * @return $this
      */
     public function prepend($val)
@@ -392,12 +395,14 @@ HTML;
             } elseif ($v instanceof Collection) {
                 return $v->prepend($val);
             }
-            return $val . $v;
+
+            return $val.$v;
         });
     }
 
     /**
      * @param string $val
+     *
      * @return $this
      */
     public function append($val)
@@ -410,14 +415,16 @@ HTML;
             } elseif ($v instanceof Collection) {
                 return $v->push($val);
             }
-            return $v . $val;
+
+            return $v.$val;
         });
     }
 
     /**
-     * Split a string by string
+     * Split a string by string.
      *
      * @param string $d
+     *
      * @return $this
      */
     public function explode(string $d = ',')
@@ -571,6 +578,7 @@ HTML;
         }
 
         $field = $this;
+
         return $this->as(function ($value) use ($extend, $field, $arguments) {
             if (!$extend->border) {
                 $field->wrap(false);
@@ -605,7 +613,6 @@ HTML;
         });
     }
 
-
     /**
      * Get all variables passed to field view.
      *
@@ -639,6 +646,7 @@ HTML;
 
                 if (!$callable instanceof \Closure) {
                     $this->value = $callable;
+
                     return;
                 }
 

+ 1 - 2
src/Show/Panel.php

@@ -3,8 +3,6 @@
 namespace Dcat\Admin\Show;
 
 use Dcat\Admin\Show;
-use Dcat\Admin\Widgets\Box;
-use Dcat\Admin\Widgets\Card;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Collection;
 
@@ -136,6 +134,7 @@ class Panel implements Renderable
      * Add variables to show view.
      *
      * @param array $variables
+     *
      * @return $this
      */
     public function with(array $variables = [])

+ 5 - 6
src/Show/Relation.php

@@ -2,7 +2,6 @@
 
 namespace Dcat\Admin\Show;
 
-use Dcat\Admin\Admin;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
 use Illuminate\Support\Fluent;
@@ -46,9 +45,9 @@ class Relation extends Field
      */
     public function __construct($name, $builder, $title = '')
     {
-        $this->name    = $name;
+        $this->name = $name;
         $this->builder = $builder;
-        $this->title   = $this->formatLabel($title);
+        $this->title = $this->formatLabel($title);
     }
 
     /**
@@ -75,11 +74,11 @@ class Relation extends Field
         $view = call_user_func($this->builder, $this->model);
 
         if ($view instanceof Show) {
-            return $this->renderTitle() . $view->render();
+            return $this->renderTitle().$view->render();
         }
 
         if (!$view instanceof Grid) {
-            return $this->renderTitle() . $view;
+            return $this->renderTitle().$view;
         }
 
         $view->setName($this->name)
@@ -96,7 +95,7 @@ class Relation extends Field
 
         $filter = "<div class='row'><div class='col-md-12'>{$filter->render()}</div></div>";
 
-        return $this->renderTitle() . $filter . $view->render();
+        return $this->renderTitle().$filter.$view->render();
     }
 
     /**

+ 4 - 4
src/Show/Tools.php

@@ -2,10 +2,8 @@
 
 namespace Dcat\Admin\Show;
 
-use Dcat\Admin\Admin;
 use Dcat\Admin\Form;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Str;
@@ -79,7 +77,7 @@ class Tools implements Renderable
     {
         $this->panel = $panel;
 
-        $this->appends  = new Collection();
+        $this->appends = new Collection();
         $this->prepends = new Collection();
     }
 
@@ -163,6 +161,7 @@ class Tools implements Renderable
 
     /**
      * @param bool $disable
+     *
      * @return $this
      */
     public function disableQuickEdit(bool $disable = true)
@@ -175,6 +174,7 @@ class Tools implements Renderable
     /**
      * @param string $width
      * @param string $height
+     *
      * @return $this
      */
     public function showQuickEdit(?string $width = null, ?string $height = null)
@@ -257,7 +257,7 @@ HTML;
         }
 
         $edit = trans('admin.edit');
-        $url  = $this->getEditPath();
+        $url = $this->getEditPath();
 
         $quickBtn = $btn = '';
 

+ 4 - 4
src/Support/Composer.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Support;
 
-use Illuminate\Contracts\Support\Arrayable;
-use Illuminate\Support\Arr;
-
 class Composer
 {
     /**
@@ -14,6 +11,7 @@ class Composer
 
     /**
      * @param $path
+     *
      * @return ComposerProperty
      */
     public static function parse(?string $path)
@@ -24,6 +22,7 @@ class Composer
     /**
      * @param null|string $packageName
      * @param null|string $lockFile
+     *
      * @return null
      */
     public static function getVersion(?string $packageName, ?string $lockFile = null)
@@ -44,6 +43,7 @@ class Composer
 
     /**
      * @param null|string $path
+     *
      * @return array
      */
     public static function readJson(?string $path)
@@ -57,7 +57,7 @@ class Composer
         }
 
         try {
-            return static::$files[$path] = (array)json_decode(app('files')->get($path), true);
+            return static::$files[$path] = (array) json_decode(app('files')->get($path), true);
         } catch (\Throwable $e) {
         }
 

+ 4 - 1
src/Support/ComposerProperty.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Support;
 
 use Illuminate\Contracts\Support\Arrayable;
-use Illuminate\Filesystem\Filesystem;
 use Illuminate\Support\Arr;
 
 /**
@@ -38,6 +37,7 @@ class ComposerProperty implements Arrayable
     /**
      * @param $key
      * @param null $default
+     *
      * @return mixed
      */
     public function get($key, $default = null)
@@ -48,6 +48,7 @@ class ComposerProperty implements Arrayable
     /**
      * @param $key
      * @param $val
+     *
      * @return $this
      */
     public function set($key, $val)
@@ -61,6 +62,7 @@ class ComposerProperty implements Arrayable
 
     /**
      * @param $key
+     *
      * @return $this
      */
     public function delete($key)
@@ -74,6 +76,7 @@ class ComposerProperty implements Arrayable
 
     /**
      * @param $name
+     *
      * @return mixed
      */
     public function __get($name)

+ 32 - 23
src/Support/Helper.php

@@ -15,12 +15,13 @@ class Helper
      * Update extension config.
      *
      * @param array $config
+     *
      * @return bool
      */
     public static function updateExtensionConfig(array $config)
     {
-        $files  = app('files');
-        $result = (bool)$files->put(config_path('admin-extensions.php'), Helper::exportArrayPhp($config));
+        $files = app('files');
+        $result = (bool) $files->put(config_path('admin-extensions.php'), self::exportArrayPhp($config));
 
         if ($result && is_file(base_path('bootstrap/cache/config.php'))) {
             Artisan::call('config:cache');
@@ -31,12 +32,12 @@ class Helper
         return $result;
     }
 
-
     /**
      * Converts the given value to an array.
      *
      * @param $value
      * @param bool $filter
+     *
      * @return array
      */
     public static function array($value, bool $filter = true)
@@ -68,7 +69,8 @@ class Helper
      *
      * @param $value
      * @param array $params
-     * @param null $bindTo
+     * @param null  $bindTo
+     *
      * @return mixed|string
      */
     public static function render($value, $params = [], $bindTo = null)
@@ -85,7 +87,7 @@ class Helper
             if ($bindTo) {
                 $value->bindTo($bindTo);
             }
-            $value = $value(...(array)$params);
+            $value = $value(...(array) $params);
         }
 
         if ($value instanceof Renderable) {
@@ -96,20 +98,21 @@ class Helper
             return $value->toHtml();
         }
 
-        return (string)$value;
+        return (string) $value;
     }
 
     /**
      * Build an HTML attribute string from an array.
      *
      * @param array $attributes
+     *
      * @return string
      */
     public static function buildHtmlAttributes($attributes)
     {
         $html = '';
 
-        foreach ((array)$attributes as $key => &$value) {
+        foreach ((array) $attributes as $key => &$value) {
             if (is_numeric($key)) {
                 $key = $value;
             }
@@ -130,7 +133,8 @@ class Helper
      * Get url with the added query string parameters.
      *
      * @param string $url
-     * @param array $query
+     * @param array  $query
+     *
      * @return string
      */
     public static function urlWithQuery(?string $url, array $query = [])
@@ -159,8 +163,9 @@ class Helper
      *      Helper::matchRequestPath('auth/user/* /edit')
      *      Helper::matchRequestPath('GET,POST:auth/user')
      *
-     * @param string $path
+     * @param string      $path
      * @param null|string $current
+     *
      * @return bool
      */
     public static function matchRequestPath($path, ?string $current = null)
@@ -190,11 +195,12 @@ class Helper
     /**
      * Build nested array.
      *
-     * @param array $nodes
-     * @param int $parentId
+     * @param array       $nodes
+     * @param int         $parentId
      * @param string|null $primaryKeyName
      * @param string|null $parentKeyName
      * @param string|null $childrenKeyName
+     *
      * @return array
      */
     public static function buildNestedArray(
@@ -205,15 +211,15 @@ class Helper
         ?string $childrenKeyName = null
     ) {
         $branch = [];
-        $primaryKeyName  = $primaryKeyName ?: 'id';
-        $parentKeyName   = $parentKeyName ?: 'parent_id';
+        $primaryKeyName = $primaryKeyName ?: 'id';
+        $parentKeyName = $parentKeyName ?: 'parent_id';
         $childrenKeyName = $childrenKeyName ?: 'children';
 
-        $parentId = is_numeric($parentId) ? (int)$parentId : $parentId;
+        $parentId = is_numeric($parentId) ? (int) $parentId : $parentId;
 
         foreach ($nodes as $node) {
             $pk = Arr::get($node, $parentKeyName);
-            $pk = is_numeric($pk) ? (int)$pk : $pk;
+            $pk = is_numeric($pk) ? (int) $pk : $pk;
 
             if ($pk === $parentId) {
                 $children = static::buildNestedArray(
@@ -239,28 +245,30 @@ class Helper
      *
      * @param string $name
      * @param string $symbol
+     *
      * @return mixed
      */
     public static function slug(string $name, string $symbol = '-')
     {
         $text = preg_replace_callback('/([A-Z])/', function (&$text) use ($symbol) {
-            return $symbol . strtolower($text[1]);
+            return $symbol.strtolower($text[1]);
         }, $name);
 
         return str_replace('_', $symbol, ltrim($text, $symbol));
     }
 
     /**
-     * 把php数据转化成文本形式
+     * 把php数据转化成文本形式.
      *
      * @param array $array
      * @param int   $level
+     *
      * @return string
      */
     public static function exportArray(array &$array, $level = 1)
     {
         $start = '[';
-        $end   = ']';
+        $end = ']';
 
         $txt = "$start\n";
 
@@ -268,7 +276,7 @@ class Helper
             if (is_array($v)) {
                 $pre = is_string($k) ? "'$k' => " : "$k => ";
 
-                $txt .= str_repeat(' ', $level * 4) . $pre . static::exportArray($v, $level + 1) . ",\n";
+                $txt .= str_repeat(' ', $level * 4).$pre.static::exportArray($v, $level + 1).",\n";
 
                 continue;
             }
@@ -287,20 +295,21 @@ class Helper
 
             $pre = is_string($k) ? "'$k' => " : "$k => ";
 
-            $txt .= str_repeat(' ', $level * 4). "{$pre}{$t},\n";
+            $txt .= str_repeat(' ', $level * 4)."{$pre}{$t},\n";
         }
 
-        return $txt . str_repeat(' ', ($level - 1) * 4) . $end;
+        return $txt.str_repeat(' ', ($level - 1) * 4).$end;
     }
 
     /**
-     * 把php数据转化成文本形式,并以"return"形式返回
+     * 把php数据转化成文本形式,并以"return"形式返回.
      *
      * @param array $array
+     *
      * @return string
      */
     public static function exportArrayPhp(array $array)
     {
-        return "<?php \nreturn " . static::exportArray($array) . ";\n";
+        return "<?php \nreturn ".static::exportArray($array).";\n";
     }
 }

+ 1 - 1
src/Support/StringOutput.php

@@ -10,7 +10,7 @@ class StringOutput extends Output
 
     public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, $formatter = null)
     {
-        $formatter = $formatter ?: new OutputFormatter;
+        $formatter = $formatter ?: new OutputFormatter();
 
         parent::__construct($verbosity, $decorated, $formatter);
     }

+ 21 - 13
src/Support/helpers.php

@@ -1,16 +1,17 @@
 <?php
 
-use Illuminate\Support\MessageBag;
-use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Contracts\Support\Htmlable;
+use Illuminate\Contracts\Support\Renderable;
+use Illuminate\Support\MessageBag;
 
 if (!function_exists('admin_section')) {
     /**
      * Get the string contents of a section.
      *
      * @param $section
-     * @param null $default
+     * @param null  $default
      * @param array $options
+     *
      * @return mixed
      */
     function admin_section($section, $default = null, array $options = [])
@@ -24,6 +25,7 @@ if (!function_exists('admin_has_section')) {
      * Check if section exists.
      *
      * @param $section
+     *
      * @return mixed
      */
     function admin_has_section($section)
@@ -39,7 +41,7 @@ if (!function_exists('admin_inject_section')) {
      * @param $section
      * @param null $content
      * @param bool $append
-     * @param int $priority
+     * @param int  $priority
      */
     function admin_inject_section($section, $content = null, bool $append = true, int $priority = 10)
     {
@@ -55,7 +57,7 @@ if (!function_exists('admin_inject_section_if')) {
      * @param $section
      * @param null $content
      * @param bool $append
-     * @param int $priority
+     * @param int  $priority
      */
     function admin_inject_section_if($condition, $section, $content = null, bool $append = false, int $priority = 10)
     {
@@ -70,6 +72,7 @@ if (!function_exists('admin_has_default_section')) {
      * Check if default section exists.
      *
      * @param $section
+     *
      * @return mixed
      */
     function admin_has_default_section($section)
@@ -97,6 +100,7 @@ if (!function_exists('admin_trans_field')) {
      *
      * @param $field
      * @param null $locale
+     *
      * @return array|\Illuminate\Contracts\Translation\Translator|null|string
      */
     function admin_trans_field($field, $locale = null)
@@ -113,13 +117,14 @@ if (!function_exists('admin_trans_label')) {
      *
      * @param $label
      * @param array $replace
-     * @param null $locale
+     * @param null  $locale
+     *
      * @return array|\Illuminate\Contracts\Translation\Translator|null|string
      */
     function admin_trans_label($label = null, $replace = [], $locale = null)
     {
         $label = $label ?: admin_controller_name();
-        $slug  = admin_controller_slug();
+        $slug = admin_controller_slug();
 
         return admin_trans("{$slug}.labels.{$label}", $replace, $locale);
     }
@@ -131,7 +136,8 @@ if (!function_exists('admin_trans_option')) {
      *
      * @param $field
      * @param array $replace
-     * @param null $locale
+     * @param null  $locale
+     *
      * @return array|\Illuminate\Contracts\Translation\Translator|null|string
      */
     function admin_trans_option($optionValue, $field, $replace = [], $locale = null)
@@ -146,9 +152,10 @@ if (!function_exists('admin_trans')) {
     /**
      * Translate the given message.
      *
-     * @param  string  $key
-     * @param  array   $replace
-     * @param  string  $locale
+     * @param string $key
+     * @param array  $replace
+     * @param string $locale
+     *
      * @return \Illuminate\Contracts\Translation\Translator|string|array|null
      */
     function admin_trans($key, $replace = [], $locale = null)
@@ -209,17 +216,18 @@ if (!function_exists('admin_controller_name')) {
 
         $router = app('router');
 
-        if (! $router->current()) {
+        if (!$router->current()) {
             return 'undefined';
         }
 
         $actionName = $router->current()->getActionName();
 
-        if (! isset($name[$actionName])) {
+        if (!isset($name[$actionName])) {
             $controller = class_basename(explode('@', $actionName)[0]);
 
             $name[$actionName] = str_replace('Controller', '', $controller);
         }
+
         return $name[$actionName];
     }
 }

+ 10 - 13
src/Traits/HasAssets.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Traits;
 
-use Dcat\Admin\Admin;
-use Dcat\Admin\Form\Field;
-
 trait HasAssets
 {
     /**
@@ -85,29 +82,29 @@ trait HasAssets
             'js' => 'vendor/dcat-admin/moment/min/moment-with-locales.min.js',
         ],
         'fontawesome-iconpicker' => [
-            'js' => 'vendor/dcat-admin/fontawesome-iconpicker/dist/js/fontawesome-iconpicker.min.js',
+            'js'  => 'vendor/dcat-admin/fontawesome-iconpicker/dist/js/fontawesome-iconpicker.min.js',
             'css' => 'vendor/dcat-admin/fontawesome-iconpicker/dist/css/fontawesome-iconpicker.min.css',
         ],
         'jstree' => [
             'js' => 'vendor/dcat-admin/jstree-theme/jstree.min.js',
         ],
         'jquery.nestable' => [
-            'js' => 'vendor/dcat-admin/nestable/jquery.nestable.min.js',
-            'css' => 'vendor/dcat-admin/nestable/nestable.css'
+            'js'  => 'vendor/dcat-admin/nestable/jquery.nestable.min.js',
+            'css' => 'vendor/dcat-admin/nestable/nestable.css',
         ],
         'switchery' => [
             'css' => 'vendor/dcat-admin/switchery/switchery.min.css',
-            'js' => 'vendor/dcat-admin/switchery/switchery.min.js'
+            'js'  => 'vendor/dcat-admin/switchery/switchery.min.js',
         ],
         'editable' => [
             'css' => 'vendor/dcat-admin/bootstrap3-editable/css/bootstrap-editable.css',
-            'js' => 'vendor/dcat-admin/bootstrap3-editable/js/bootstrap-editable.min.js'
+            'js'  => 'vendor/dcat-admin/bootstrap3-editable/js/bootstrap-editable.min.js',
         ],
         'chartjs' => [
-            'js' => 'vendor/dcat-admin/chart.js/chart.bundle.min.js'
+            'js' => 'vendor/dcat-admin/chart.js/chart.bundle.min.js',
         ],
         'jquery.sparkline' => [
-            'js' => 'vendor/dcat-admin/jquery.sparkline/jquery.sparkline.min.js'
+            'js' => 'vendor/dcat-admin/jquery.sparkline/jquery.sparkline.min.js',
         ],
         'jquery.counterup' => [
             'js' => 'vendor/dcat-admin/jquery.counterup/jquery.counterup.min.js',
@@ -154,7 +151,7 @@ trait HasAssets
 
         static::$componentsAssets['select2']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js';
         static::$componentsAssets['select2']['css'] = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css';
-        static::$componentsAssets['jquery.bootstrap-duallistbox']['js']  = 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap4-duallistbox/3.0.7/jquery.bootstrap-duallistbox.min.js';
+        static::$componentsAssets['jquery.bootstrap-duallistbox']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap4-duallistbox/3.0.7/jquery.bootstrap-duallistbox.min.js';
         static::$componentsAssets['jquery.inputmask']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.0/jquery.inputmask.bundle.min.js';
         static::$componentsAssets['bootstrap-datetimepicker']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js';
         static::$componentsAssets['bootstrap-datetimepicker']['css'] = 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css';
@@ -166,7 +163,7 @@ trait HasAssets
         static::$componentsAssets['switchery']['css'] = 'https://cdnjs.cloudflare.com/ajax/libs/switchery/0.8.2/switchery.min.css';
         static::$componentsAssets['editable']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js';
         static::$componentsAssets['editable']['css'] = 'https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/bootstrap-editable/css/bootstrap-editable.css';
-        static::$componentsAssets['chartjs']['js'] =  'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js';
+        static::$componentsAssets['chartjs']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js';
         static::$componentsAssets['jquery.sparkline']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.2/jquery.sparkline.min.js';
         static::$componentsAssets['waypoints']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/waypoints/3.1.1/jquery.waypoints.min.js';
         static::$componentsAssets['jquery.counterup']['js'] = 'https://cdnjs.cloudflare.com/ajax/libs/Counter-Up/1.0.0/jquery.counterup.min.js';
@@ -177,7 +174,7 @@ trait HasAssets
      */
     public static function collectComponentAssets(string $name)
     {
-        $js  = static::$componentsAssets[$name]['js'] ?? null;
+        $js = static::$componentsAssets[$name]['js'] ?? null;
         $css = static::$componentsAssets[$name]['css'] ?? null;
 
         $js && static::js($js);

+ 4 - 4
src/Traits/HasBuilderEvents.php

@@ -8,7 +8,7 @@ trait HasBuilderEvents
      * Register a resolving listener.
      *
      * @param callable $callback
-     * @param bool $once
+     * @param bool     $once
      */
     public static function resolving(callable $callback, bool $once = false)
     {
@@ -27,7 +27,7 @@ trait HasBuilderEvents
      * Register a composing listener.
      *
      * @param callable $callback
-     * @param bool $once
+     * @param bool     $once
      */
     public static function composing(callable $callback, bool $once = false)
     {
@@ -68,9 +68,9 @@ trait HasBuilderEvents
     }
 
     /**
-     * @param string $key
+     * @param string   $key
      * @param callable $callback
-     * @param bool $once
+     * @param bool     $once
      */
     protected static function setListeners($key, $callback, $once)
     {

+ 1 - 0
src/Traits/HasDefinitions.php

@@ -24,6 +24,7 @@ trait HasDefinitions
 
     /**
      * @param string $name
+     *
      * @return bool
      */
     public static function hasDefinition(string $name)

+ 7 - 2
src/Traits/HasHtmlAttributes.php

@@ -14,7 +14,8 @@ trait HasHtmlAttributes
 
     /**
      * @param string|array $key
-     * @param mixed $value
+     * @param mixed        $value
+     *
      * @return $this
      */
     public function setHtmlAttribute($key, $value = null)
@@ -31,6 +32,7 @@ trait HasHtmlAttributes
 
     /**
      * @param string|array $keys
+     *
      * @return $this
      */
     public function forgetHtmlAttribute($keys)
@@ -52,7 +54,8 @@ trait HasHtmlAttributes
      * Set default attribute.
      *
      * @param string $attribute
-     * @param mixed $value
+     * @param mixed  $value
+     *
      * @return $this
      */
     public function defaultHtmlAttribute($attribute, $value)
@@ -67,6 +70,7 @@ trait HasHtmlAttributes
     /**
      * @param mixed $key
      * @param mixed $default
+     *
      * @return |null
      */
     public function getHtmlAttribute($key, $default = null)
@@ -76,6 +80,7 @@ trait HasHtmlAttributes
 
     /**
      * @param mixed $key
+     *
      * @return |null
      */
     public function hasHtmlAttribute($key)

+ 1 - 1
src/Traits/ModelTree.php

@@ -291,7 +291,7 @@ trait ModelTree
 
                 Request::offsetUnset('_order');
 
-                Tree::make(new static)->saveOrder($order);
+                Tree::make(new static())->saveOrder($order);
 
                 return false;
             }

+ 7 - 5
src/Tree.php

@@ -104,7 +104,6 @@ class Tree implements Renderable
      */
     public $useDelete = true;
 
-
     /**
      * @var array
      */
@@ -130,8 +129,8 @@ class Tree implements Renderable
     public function __construct(Model $model = null, ?\Closure $callback = null)
     {
         $this->model = $model;
-        $this->path  = $this->path ?: request()->getPathInfo();
-        $this->url   = url($this->path);
+        $this->path = $this->path ?: request()->getPathInfo();
+        $this->url = url($this->path);
 
         $this->elementId .= uniqid();
 
@@ -233,6 +232,7 @@ class Tree implements Renderable
     /**
      * @param string $width
      * @param string $height
+     *
      * @return $this
      */
     public function setdialogFormDimensions(string $width, string $height)
@@ -279,6 +279,7 @@ class Tree implements Renderable
 
     /**
      * @param Closure $closure
+     *
      * @return $this;
      */
     public function wrap(\Closure $closure)
@@ -451,7 +452,7 @@ JS;
             return '';
         }
 
-        $url = $this->url . '/create';
+        $url = $this->url.'/create';
         $new = trans('admin.new');
 
         $quickBtn = $btn = '';
@@ -556,8 +557,9 @@ JS;
     /**
      * Create a tree instance.
      *
-     * @param Model|null $model
+     * @param Model|null   $model
      * @param Closure|null $callback
+     *
      * @return Tree
      */
     public static function make(Model $model = null, \Closure $callback = null)

+ 1 - 3
src/Tree/Tools.php

@@ -4,7 +4,6 @@ namespace Dcat\Admin\Tree;
 
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Tree;
-use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Collection;
 
@@ -26,11 +25,10 @@ class Tools implements Renderable
 
     /**
      * Create a new Tools instance.
-     *
      */
     public function __construct(Tree $tree)
     {
-        $this->tree  = $tree;
+        $this->tree = $tree;
         $this->tools = new Collection();
     }
 

+ 10 - 3
src/Widgets/AjaxRequestBuilder.php

@@ -33,6 +33,7 @@ trait AjaxRequestBuilder
      * Set request url.
      *
      * @param string $url
+     *
      * @return $this
      */
     public function request(string $url)
@@ -44,6 +45,7 @@ trait AjaxRequestBuilder
      * Set current url to request.
      *
      * @param string $url
+     *
      * @return $this
      */
     public function requestCurrent(array $query = [])
@@ -57,6 +59,7 @@ trait AjaxRequestBuilder
      * Set request url.
      *
      * @param string $url
+     *
      * @return $this
      */
     public function setUrl(string $url)
@@ -86,12 +89,13 @@ trait AjaxRequestBuilder
      * Set css selectors of refetch links.
      *
      * @param string|array $selector
+     *
      * @return $this
      */
     public function refetch($selector)
     {
         $this->buttonSelectors =
-            array_merge($this->buttonSelectors, (array)$selector);
+            array_merge($this->buttonSelectors, (array) $selector);
 
         return $this;
     }
@@ -108,6 +112,7 @@ trait AjaxRequestBuilder
      * Set the script before fetch data.
      *
      * @param string $script
+     *
      * @return $this
      */
     public function fetching(string $script)
@@ -121,6 +126,7 @@ trait AjaxRequestBuilder
      * Set the script after fetch data.
      *
      * @param string $script
+     *
      * @return $this
      */
     public function fetched(string $script)
@@ -150,7 +156,7 @@ trait AjaxRequestBuilder
         $this->fn = 'frd_'.Str::random(8);
 
         $fetching = implode(';', $this->javascripts['fetching']);
-        $fetched  = implode(';', $this->javascripts['fetched']);
+        $fetched = implode(';', $this->javascripts['fetched']);
 
         $binding = '';
         foreach ($this->buttonSelectors as $v) {
@@ -173,6 +179,7 @@ JS;
      * Copy the given AjaxRequestBuilder.
      *
      * @param AjaxRequestBuilder $fetcher
+     *
      * @return $this
      */
     public function copy($fetcher)
@@ -184,7 +191,7 @@ JS;
         $scripts = $fetcher->getJavascripts();
 
         $this->javascripts['fetching'] = array_merge($this->javascripts['fetching'], $scripts['fetching']);
-        $this->javascripts['fetched']  = array_merge($this->javascripts['fetched'], $scripts['fetched']);
+        $this->javascripts['fetched'] = array_merge($this->javascripts['fetched'], $scripts['fetched']);
 
         return $this;
     }

+ 4 - 1
src/Widgets/Alert.php

@@ -56,6 +56,7 @@ class Alert extends Widget
      * Set title.
      *
      * @param string $title
+     *
      * @return $this
      */
     public function title($title)
@@ -69,6 +70,7 @@ class Alert extends Widget
      * Set contents.
      *
      * @param string|\Closure|Renderable $content
+     *
      * @return $this
      */
     public function content($content)
@@ -112,11 +114,12 @@ class Alert extends Widget
      * Disable close button.
      *
      * @param bool $value
+     *
      * @return $this
      */
     public function disableCloseButton(bool $value = true)
     {
-        $this->showCloseBtn = ! $value;
+        $this->showCloseBtn = !$value;
 
         return $this;
     }

+ 2 - 1
src/Widgets/Box.php

@@ -139,13 +139,14 @@ class Box extends Widget
     }
 
     /**
-     *
      * @param string|Renderable|\Closure $content
+     *
      * @return $this
      */
     public function tool($content)
     {
         $this->tools[] = $this->toString($content);
+
         return $this;
     }
 

+ 2 - 1
src/Widgets/Card.php

@@ -75,13 +75,14 @@ class Card extends Widget
     }
 
     /**
-     *
      * @param string|Renderable|\Closure $content
+     *
      * @return $this
      */
     public function tool($content)
     {
         $this->tools[] = $this->toString($content);
+
         return $this;
     }
 

+ 2 - 0
src/Widgets/Chart/Bar.php

@@ -15,6 +15,7 @@ class Bar extends Chart
      * Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other.
      *
      * @param number $val default 0.9
+     *
      * @return $this
      */
     public function barPercentage($val)
@@ -26,6 +27,7 @@ class Bar extends Chart
      * Percent (0-1) of the available width each category should be within the sample width.
      *
      * @param number $val default 0.8
+     *
      * @return $this
      */
     public function categoryPercentage($val)

+ 25 - 7
src/Widgets/Chart/Chart.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Widgets\Chart;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Widgets\Color;
 use Dcat\Admin\Widgets\AjaxRequestBuilder;
+use Dcat\Admin\Widgets\Color;
 use Dcat\Admin\Widgets\Widget;
 use Illuminate\Support\Str;
 
@@ -45,6 +45,7 @@ abstract class Chart extends Widget
 
     /**
      * Chart constructor.
+     *
      * @param mixed ...$params
      */
     public function __construct(...$params)
@@ -69,9 +70,10 @@ abstract class Chart extends Widget
      * Composite the chart.
      *
      * @param Chart $chart
+     *
      * @return $this
      */
-    public function composite(Chart $chart)
+    public function composite(self $chart)
     {
         $this->data['datasets']
             = array_merge($this->data['datasets'], $chart->getDatasets());
@@ -83,6 +85,7 @@ abstract class Chart extends Widget
      * Set labels.
      *
      * @param $labels
+     *
      * @return $this
      */
     public function labels(array $labels)
@@ -102,8 +105,9 @@ abstract class Chart extends Widget
      *     ]);
      *
      * @param string|array $label
-     * @param array $data
+     * @param array        $data
      * @param string|array $fillColor
+     *
      * @return $this
      */
     public function add($label, $data = [], $fillColor = null)
@@ -145,6 +149,7 @@ abstract class Chart extends Widget
 
     /**
      * @param bool $val
+     *
      * @return $this
      */
     public function responsive(bool $val = true)
@@ -156,6 +161,7 @@ abstract class Chart extends Widget
      * @see https://www.chartjs.org/docs/latest/configuration/legend.html
      *
      * @param array $opts
+     *
      * @return $this
      */
     public function legend(array $opts)
@@ -189,6 +195,7 @@ abstract class Chart extends Widget
      * @see https://www.chartjs.org/docs/latest/configuration/tooltip.html
      *
      * @param array $opts
+     *
      * @return $this
      */
     public function tooltips(array $opts)
@@ -216,6 +223,7 @@ abstract class Chart extends Widget
      * @see https://www.chartjs.org/docs/latest/configuration/title.html
      *
      * @param array $options
+     *
      * @return $this
      */
     public function title($options)
@@ -233,6 +241,7 @@ abstract class Chart extends Widget
      * @see https://www.chartjs.org/docs/latest/configuration/elements.html
      *
      * @param array $options
+     *
      * @return $this
      */
     public function elements(array $options)
@@ -250,6 +259,7 @@ abstract class Chart extends Widget
      * @see https://www.chartjs.org/docs/latest/configuration/layout.html
      *
      * @param array $opts
+     *
      * @return $this
      */
     public function layout(array $opts)
@@ -267,6 +277,7 @@ abstract class Chart extends Widget
      * The padding to add inside the chart.
      *
      * @param array|int $opts
+     *
      * @return Chart
      */
     public function padding($opts)
@@ -276,6 +287,7 @@ abstract class Chart extends Widget
 
     /**
      * @param array $opts
+     *
      * @return $this
      */
     public function animation(array $opts)
@@ -293,6 +305,7 @@ abstract class Chart extends Widget
      * Set width of container.
      *
      * @param string $width
+     *
      * @return Chart
      */
     public function width($width)
@@ -304,6 +317,7 @@ abstract class Chart extends Widget
      * Set height of container.
      *
      * @param string $height
+     *
      * @return Chart
      */
     public function height($height)
@@ -313,7 +327,8 @@ abstract class Chart extends Widget
 
     /**
      * @param string $style
-     * @param bool $append
+     * @param bool   $append
+     *
      * @return $this
      */
     public function setContainerStyle(string $style, bool $append = true)
@@ -331,6 +346,7 @@ abstract class Chart extends Widget
      * Fill default color.
      *
      * @param array $colors
+     *
      * @return void
      */
     protected function fillColor(array $colors = [])
@@ -451,7 +467,8 @@ HTML;
 
     /**
      * @param string $method
-     * @param array $parameters
+     * @param array  $parameters
+     *
      * @return $this
      */
     public function __call($method, $parameters)
@@ -468,8 +485,9 @@ HTML;
     /**
      * Return JsonResponse instance.
      *
-     * @param bool $returnOptions
+     * @param bool  $returnOptions
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     public function toJsonResponse(bool $returnOptions = true, array $data = [])
@@ -489,7 +507,7 @@ HTML;
      */
     protected function setDefaultColors()
     {
-        if (! $this->colors) {
+        if (!$this->colors) {
             $this->colors = Color::$chartTheme['blue'];
         }
     }

+ 0 - 3
src/Widgets/Chart/Doughnut.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets\Chart;
 
-use Dcat\Admin\Admin;
-use Illuminate\Support\Arr;
-
 /**
  * @see https://www.chartjs.org/docs/latest/charts/doughnut.html
  */

+ 2 - 4
src/Widgets/Chart/Pie.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets\Chart;
 
-use Dcat\Admin\Admin;
-use Illuminate\Support\Arr;
-
 /**
  * @see https://www.chartjs.org/docs/latest/charts/doughnut.html
  */
@@ -19,8 +16,9 @@ class Pie extends Chart
      *     $this->add([1, 23, 6, 10, 6]);
      *
      * @param string|array $label
-     * @param array $data
+     * @param array        $data
      * @param string|array $fillColor
+     *
      * @return $this
      */
     public function add($data = [], $fillColor = null, $none = null)

+ 0 - 3
src/Widgets/Chart/PolarArea.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets\Chart;
 
-use Dcat\Admin\Admin;
-use Illuminate\Support\Arr;
-
 class PolarArea extends Pie
 {
     protected $type = 'polarArea';

+ 0 - 3
src/Widgets/Chart/Radar.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets\Chart;
 
-use Dcat\Admin\Admin;
-use Illuminate\Support\Arr;
-
 class Radar extends Line
 {
     protected $type = 'radar';

+ 8 - 3
src/Widgets/Chart/ScaleSetting.php

@@ -4,11 +4,11 @@ namespace Dcat\Admin\Widgets\Chart;
 
 trait ScaleSetting
 {
-
     /**
      * @see https://www.chartjs.org/docs/latest/axes/
      *
      * @param array $opts
+     *
      * @return $this
      */
     public function scales(array $opts)
@@ -24,6 +24,7 @@ trait ScaleSetting
 
     /**
      * @param string|null $label
+     *
      * @return $this
      */
     public function displayScaleLabelOnX(?string $label)
@@ -31,7 +32,7 @@ trait ScaleSetting
         return $this->xAxes([
             [
                 'scaleLabel' => [
-                    'display' => true,
+                    'display'     => true,
                     'labelString' => $label,
                 ],
             ],
@@ -40,6 +41,7 @@ trait ScaleSetting
 
     /**
      * @param string|null $label
+     *
      * @return $this
      */
     public function displayScaleLabelOnY(?string $label)
@@ -47,7 +49,7 @@ trait ScaleSetting
         return $this->yAxes([
             [
                 'scaleLabel' => [
-                    'display' => true,
+                    'display'     => true,
                     'labelString' => $label,
                 ],
             ],
@@ -56,6 +58,7 @@ trait ScaleSetting
 
     /**
      * @param array $opts
+     *
      * @return $this
      */
     public function yAxes(array $opts)
@@ -65,6 +68,7 @@ trait ScaleSetting
 
     /**
      * @param array $opts
+     *
      * @return $this
      */
     public function xAxes(array $opts)
@@ -76,6 +80,7 @@ trait ScaleSetting
      * @see https://www.chartjs.org/docs/latest/axes/radial/linear.html
      *
      * @param array $opts
+     *
      * @return $this
      */
     public function scale(array $opts)

+ 3 - 2
src/Widgets/Checkbox.php

@@ -16,17 +16,19 @@ class Checkbox extends Radio
 
     /**
      * @param $id
+     *
      * @return $this
      */
     public function checked($id)
     {
-        $this->checked = (array)$id;
+        $this->checked = (array) $id;
 
         return $this;
     }
 
     /**
      * @param $excepts
+     *
      * @return Checkbox
      */
     public function checkedAll($excepts = [])
@@ -46,7 +48,6 @@ class Checkbox extends Radio
         return $this->circle(false);
     }
 
-
     public function variables()
     {
         $v = parent::variables();

+ 11 - 8
src/Widgets/Code.php

@@ -13,8 +13,8 @@ class Code extends Markdown
 
     /**
      * @param string $content
-     * @param int $start
-     * @param int $end
+     * @param int    $start
+     * @param int    $end
      */
     public function __construct($content = '', int $start = 1, int $end = 10)
     {
@@ -30,6 +30,7 @@ class Code extends Markdown
      * 设置语言
      *
      * @param string $lang
+     *
      * @return $this
      */
     public function lang(string $lang)
@@ -68,11 +69,12 @@ class Code extends Markdown
     }
 
     /**
-     * 读取指定行上下区间文件内容
+     * 读取指定行上下区间文件内容.
      *
      * @param string $file
-     * @param int $lineNumber
-     * @param int $padding
+     * @param int    $lineNumber
+     * @param int    $padding
+     *
      * @return $this
      */
     public function padding($file, $lineNumber = 1, $padding = 5)
@@ -81,11 +83,12 @@ class Code extends Markdown
     }
 
     /**
-     * 读取指定行文件内容
+     * 读取指定行文件内容.
      *
      * @param string $file
-     * @param int $start
-     * @param int $end
+     * @param int    $start
+     * @param int    $end
+     *
      * @return $this
      */
     public function read($file, $start = 1, $end = 10)

+ 1 - 1
src/Widgets/Color.php

@@ -89,7 +89,7 @@ class Color
         'dark90'        => '#252d37',
         'dark90half'    => '#5c7089',
     ];
-    
+
     public static $default = [
         'green' => [
             'rgba(33,185,120, 1)',

+ 13 - 6
src/Widgets/DataCard/Card.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Widgets\DataCard;
 
 use Dcat\Admin\Admin;
-use Dcat\Admin\Widgets\Dropdown;
 use Dcat\Admin\Widgets\AjaxRequestBuilder;
+use Dcat\Admin\Widgets\Dropdown;
 use Dcat\Admin\Widgets\Widget;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Str;
@@ -58,6 +58,7 @@ class Card extends Widget
 
     /**
      * @param $number
+     *
      * @return $this
      */
     public function number($number)
@@ -67,7 +68,8 @@ class Card extends Widget
 
     /**
      * @param string|\Closure|Renderable $content
-     * @param string $position
+     * @param string                     $position
+     *
      * @return $this
      */
     public function content($content, string $position = 'left')
@@ -79,6 +81,7 @@ class Card extends Widget
 
     /**
      * @param string|\Closure|Renderable $content
+     *
      * @return $this
      */
     public function rightContent($content)
@@ -87,8 +90,9 @@ class Card extends Widget
     }
 
     /**
-     * @param int $number
+     * @param int    $number
      * @param string $style
+     *
      * @return $this
      */
     public function progress($number, $style = 'primary')
@@ -103,6 +107,7 @@ class Card extends Widget
 
     /**
      * @param string|\Closure|Renderable $content
+     *
      * @return $this
      */
     public function tool($content)
@@ -113,9 +118,10 @@ class Card extends Widget
     }
 
     /**
-     * @param array $options
-     * @param \Closure $builder
+     * @param array       $options
+     * @param \Closure    $builder
      * @param string|null $defaultLabel
+     *
      * @return $this
      */
     public function dropdown(array $options, \Closure $builder, ?string $defaultLabel = null)
@@ -160,7 +166,7 @@ JS
         );
 
         $this->fetched(
-            <<<JS
+            <<<'JS'
 if (!result.status) {
     return LA.error(result.message || 'Server internal error.');
 }     
@@ -202,6 +208,7 @@ JS
      * Return JsonResponse instance.
      *
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     public function toJsonResponse(array $data = [])

+ 3 - 2
src/Widgets/DataCard/DoughnutChartCard.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Widgets\DataCard;
 
 use Dcat\Admin\Widgets\Chart\Doughnut;
-use Dcat\Admin\Widgets\Color;
 use Illuminate\Contracts\Support\Arrayable;
 
 class DoughnutChartCard extends Card
@@ -53,7 +52,8 @@ class DoughnutChartCard extends Card
 
     /**
      * @param \Closure|array $builder
-     * @param array $data
+     * @param array          $data
+     *
      * @return $this
      */
     public function chart($builder, array $data = [])
@@ -154,6 +154,7 @@ HTML;
      * Return JsonResponse instance.
      *
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     public function toJsonResponse(array $data = [])

+ 1 - 0
src/Widgets/DataCard/LineChartCard.php

@@ -55,6 +55,7 @@ class LineChartCard extends Card
      * Return JsonResponse instance.
      *
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     public function toJsonResponse(array $data = [])

+ 13 - 4
src/Widgets/Dropdown.php

@@ -64,8 +64,9 @@ class Dropdown extends Widget
     /**
      * Set the options of dropdown menus.
      *
-     * @param array $options
+     * @param array       $options
      * @param string|null $title
+     *
      * @return $this
      */
     public function options($options = [], string $title = null)
@@ -78,7 +79,7 @@ class Dropdown extends Widget
             $options = $options->toArray();
         }
 
-        $options = (array)$options;
+        $options = (array) $options;
 
         if (!$this->options) {
             $this->firstOptions = &$options;
@@ -93,6 +94,7 @@ class Dropdown extends Widget
      * Set the button text.
      *
      * @param string|null $text
+     *
      * @return $this
      */
     public function button(?string $text)
@@ -116,6 +118,7 @@ class Dropdown extends Widget
      * Set the button class.
      *
      * @param string $class
+     *
      * @return $this
      */
     public function buttonClass(string $class)
@@ -129,6 +132,7 @@ class Dropdown extends Widget
      * Set the button style.
      *
      * @param string $class
+     *
      * @return $this
      */
     public function buttonStyle(string $style)
@@ -142,6 +146,7 @@ class Dropdown extends Widget
      * Show divider.
      *
      * @param string $class
+     *
      * @return $this
      */
     public function divider()
@@ -155,6 +160,7 @@ class Dropdown extends Widget
      * Applies the callback to the elements of the options.
      *
      * @param string $class
+     *
      * @return $this
      */
     public function map(\Closure $builder)
@@ -168,6 +174,7 @@ class Dropdown extends Widget
      * Add click event listener.
      *
      * @param string|null $defaultLabel
+     *
      * @return $this
      */
     public function click(?string $defaultLabel = null)
@@ -187,6 +194,7 @@ class Dropdown extends Widget
      * Set the template of dropdown menu.
      *
      * @param string|\Closure|Renderable $template
+     *
      * @return $this
      */
     public function template($template)
@@ -205,7 +213,7 @@ class Dropdown extends Widget
             return;
         }
 
-        $text  = $this->button['text'];
+        $text = $this->button['text'];
         $class = $this->button['class'];
         $style = $this->button['style'];
 
@@ -227,7 +235,7 @@ class Dropdown extends Widget
                 $this->buttonId,
                 $class,
                 $style ? "style='$style'" : '',
-                $text ? " $text &nbsp;" : ''
+                $text ? " $text &nbsp;" : '',
             ],
             <<<'HTML'
 <a id="{id}" class="{class} dropdown-toggle " data-toggle="dropdown" href="javascript:void(0)" {style}>
@@ -271,6 +279,7 @@ HTML
     /**
      * @param mixed $k
      * @param mixed $v
+     *
      * @return mixed|string
      */
     protected function renderOption($k, $v)

+ 4 - 1
src/Widgets/Dump.php

@@ -27,7 +27,7 @@ class Dump extends Widget
      * Dump constructor.
      *
      * @param array|object|string $content
-     * @param string|null $padding
+     * @param string|null         $padding
      */
     public function __construct($content, string $padding = null)
     {
@@ -52,6 +52,7 @@ class Dump extends Widget
 
     /**
      * @param string|null $padding
+     *
      * @return $this
      */
     public function padding(?string $padding)
@@ -65,6 +66,7 @@ class Dump extends Widget
 
     /**
      * @param string $width
+     *
      * @return $this
      */
     public function maxWidth($width)
@@ -76,6 +78,7 @@ class Dump extends Widget
 
     /**
      * @param mixed $content
+     *
      * @return array|null
      */
     protected function convertJsonToArray($content)

+ 9 - 4
src/Widgets/Form.php

@@ -9,11 +9,11 @@ use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Traits\HasHtmlAttributes;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Collection;
-use Illuminate\Support\Traits\Macroable;
 use Illuminate\Support\Arr;
+use Illuminate\Support\Collection;
 use Illuminate\Support\Fluent;
 use Illuminate\Support\Str;
+use Illuminate\Support\Traits\Macroable;
 
 /**
  * Class Form.
@@ -68,7 +68,6 @@ use Illuminate\Support\Str;
  * @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 = '')
@@ -204,6 +203,7 @@ class Form implements Renderable
      * Set primary key.
      *
      * @param mixed $value
+     *
      * @return $this
      */
     public function key($value)
@@ -223,6 +223,7 @@ class Form implements Renderable
 
     /**
      * @param array|Arrayable|Closure $data
+     *
      * @return $this
      */
     public function data($data)
@@ -234,6 +235,7 @@ class Form implements Renderable
 
     /**
      * @param array|Arrayable|Closure $data
+     *
      * @return $this
      */
     public function fill($data)
@@ -246,7 +248,7 @@ class Form implements Renderable
      */
     public function model()
     {
-        if (! $this->data) {
+        if (!$this->data) {
             $this->data([]);
         }
 
@@ -278,6 +280,7 @@ class Form implements Renderable
      * Get specify field.
      *
      * @param string|Field $name
+     *
      * @return Field|null
      */
     public function field($name)
@@ -463,6 +466,7 @@ HTML;
 
     /**
      * @param $id
+     *
      * @return $this
      */
     public function setFormId($id)
@@ -509,6 +513,7 @@ HTML;
      * Disable submit with ajax.
      *
      * @param bool $disable
+     *
      * @return $this
      */
     public function disableAjaxSubmit(bool $disable = true)

+ 11 - 9
src/Widgets/Markdown.php

@@ -14,16 +14,16 @@ class Markdown extends Widget
     protected $content;
 
     /**
-     * 配置
+     * 配置.
      *
      * @var array
      */
     protected $options = [
-        'htmlDecode' => 'style,script,iframe',
-        'emoji' => true,
-        'taskList' => true,
-        'tex' => true,
-        'flowChart' => true,
+        'htmlDecode'      => 'style,script,iframe',
+        'emoji'           => true,
+        'taskList'        => true,
+        'tex'             => true,
+        'flowChart'       => true,
         'sequenceDiagram' => true,
     ];
 
@@ -33,7 +33,7 @@ class Markdown extends Widget
 
         Admin::css([
             'vendor/dcat-admin/editor-md/css/editormd.preview.min.css',
-            'vendor/dcat-admin/dcat-admin/markdown.css'
+            'vendor/dcat-admin/dcat-admin/markdown.css',
         ]);
 
         Admin::js([
@@ -44,13 +44,14 @@ class Markdown extends Widget
             'vendor/dcat-admin/editor-md/lib/sequence-diagram.min.js',
             'vendor/dcat-admin/editor-md/lib/flowchart.min.js',
             'vendor/dcat-admin/editor-md/lib/jquery.flowchart.min.js',
-            'vendor/dcat-admin/editor-md/editormd.min.js'
+            'vendor/dcat-admin/editor-md/editormd.min.js',
         ]);
     }
 
     /**
      * @param mixed $k
      * @param mixed $v
+     *
      * @return $this
      */
     public function option($k, $v)
@@ -61,13 +62,14 @@ class Markdown extends Widget
     }
 
     /**
-     *
      * @param string|Renderable $markdown
+     *
      * @return $this
      */
     public function content($markdown)
     {
         $this->content = &$markdown;
+
         return $this;
     }
 

+ 21 - 13
src/Widgets/ModalForm.php

@@ -48,8 +48,8 @@ class ModalForm
     }
 
     /**
-     *
      * @param array $options
+     *
      * @return $this
      */
     public function options($options = [])
@@ -64,9 +64,10 @@ class ModalForm
     }
 
     /**
-     * 设置弹窗标题
+     * 设置弹窗标题.
      *
      * @param string $title
+     *
      * @return $this
      */
     public function title(?string $title)
@@ -77,9 +78,10 @@ class ModalForm
     }
 
     /**
-     * 绑定点击按钮
+     * 绑定点击按钮.
      *
      * @param string $buttonSelector
+     *
      * @return $this
      */
     public function click(string $buttonSelector)
@@ -90,7 +92,7 @@ class ModalForm
     }
 
     /**
-     * 强制每次点击按钮都重新渲染表单弹窗
+     * 强制每次点击按钮都重新渲染表单弹窗.
      *
      * @return $this
      */
@@ -102,7 +104,7 @@ class ModalForm
     }
 
     /**
-     * 禁用重置按钮
+     * 禁用重置按钮.
      *
      * @return $this
      */
@@ -114,9 +116,10 @@ class ModalForm
     }
 
     /**
-     * 保存后触发的js的代码(不论成功还是失败)
+     * 保存后触发的js的代码(不论成功还是失败).
      *
      * @param string $script
+     *
      * @return $this
      */
     public function saved(string $script)
@@ -130,6 +133,7 @@ class ModalForm
      * 保存失败时触发的js代码
      *
      * @param string $script
+     *
      * @return $this
      */
     public function error(string $script)
@@ -143,6 +147,7 @@ class ModalForm
      * 保存成功后触发的js代码
      *
      * @param string $script
+     *
      * @return $this
      */
     public function success(string $script)
@@ -154,10 +159,11 @@ class ModalForm
 
     /**
      * 设置弹窗宽高
-     * 支持百分比和"px"
+     * 支持百分比和"px".
      *
      * @param string $width
      * @param string $height
+     *
      * @return $this
      */
     public function dimensions(string $width, string $height)
@@ -167,12 +173,12 @@ class ModalForm
         return $this;
     }
 
-
     /**
      * 设置弹窗宽度
-     * 支持百分比和"px"
+     * 支持百分比和"px".
      *
      * @param string|null $width
+     *
      * @return $this
      */
     public function width(?string $width)
@@ -184,9 +190,10 @@ class ModalForm
 
     /**
      * 设置弹窗高度
-     * 支持百分比和"px"
+     * 支持百分比和"px".
      *
      * @param string|null $height
+     *
      * @return $this
      */
     public function height(?string $height)
@@ -197,9 +204,10 @@ class ModalForm
     }
 
     /**
-     * 设置默认的表单页面url
+     * 设置默认的表单页面url.
      *
      * @param null|string $url
+     *
      * @return $this
      */
     public function url(?string $url)
@@ -274,8 +282,8 @@ JS
         }
 
         Admin::$baseCss = [];
-        Admin::$baseJs  = [];
-        Admin::$fonts   = '';
+        Admin::$baseJs = [];
+        Admin::$fonts = '';
 
         Admin::$disableSkinCss = true;
 

+ 1 - 1
src/Widgets/NavList.php

@@ -47,7 +47,7 @@ class NavList extends Widget
             $items = $items->toArray();
         }
 
-        $this->items = (array)$items;
+        $this->items = (array) $items;
 
         return $this;
     }

+ 2 - 3
src/Widgets/Navbar.php

@@ -4,7 +4,6 @@ namespace Dcat\Admin\Widgets;
 
 use Dcat\Admin\Admin;
 use Dcat\Admin\Support\Helper;
-use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Support\Str;
 
 class Navbar extends Widget
@@ -27,7 +26,7 @@ class Navbar extends Widget
      */
     protected $items = [
         'right' => [],
-        'left' => [],
+        'left'  => [],
     ];
 
     protected $active;
@@ -43,7 +42,7 @@ class Navbar extends Widget
         $this->add($items);
 
         $this->class('navbar navbar-default');
-        $this->id = 'navbar-' . Str::random(8);
+        $this->id = 'navbar-'.Str::random(8);
     }
 
     public function title($title)

+ 6 - 3
src/Widgets/Radio.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Widgets;
 
 use Illuminate\Contracts\Support\Arrayable;
-use Illuminate\Support\Str;
 
 class Radio extends Widget
 {
@@ -28,12 +27,13 @@ class Radio extends Widget
 
     /**
      * @param null $options
+     *
      * @return $this
      */
     public function disabled($options = null)
     {
         if ($options) {
-            $this->disabledValues = (array)$options;
+            $this->disabledValues = (array) $options;
 
             return $this;
         }
@@ -55,6 +55,7 @@ class Radio extends Widget
 
     /**
      * @param $id
+     *
      * @return $this
      */
     public function checked($id)
@@ -72,6 +73,7 @@ class Radio extends Widget
      *         2 => 'bar',
      *         ...
      *     ]
+     *
      * @param array $opts
      *
      * @return $this
@@ -87,9 +89,10 @@ class Radio extends Widget
     }
 
     /**
-     * "info", "primary", "inverse", "danger", "success", "purple"
+     * "info", "primary", "inverse", "danger", "success", "purple".
      *
      * @param $v
+     *
      * @return $this
      */
     public function style($v)

+ 0 - 3
src/Widgets/Sparkline/Bar.php

@@ -2,9 +2,6 @@
 
 namespace Dcat\Admin\Widgets\Sparkline;
 
-use Dcat\Admin\Admin;
-use Illuminate\Contracts\Support\Arrayable;
-
 /**
  * @see https://omnipotent.net/jquery.sparkline
  *

+ 12 - 5
src/Widgets/Sparkline/Sparkline.php

@@ -88,6 +88,7 @@ class Sparkline extends Widget
      * Get or set the sparkline values.
      *
      * @param mixed|null $values
+     *
      * @return $this|array
      */
     public function values($values = null)
@@ -111,6 +112,7 @@ class Sparkline extends Widget
      * Set width of sparkline.
      *
      * @param int $width
+     *
      * @return $this
      */
     public function width($width)
@@ -124,6 +126,7 @@ class Sparkline extends Widget
      * Set height of sparkline.
      *
      * @param int $width
+     *
      * @return $this
      */
     public function height($height)
@@ -139,9 +142,10 @@ class Sparkline extends Widget
      * Composite the given sparkline.
      *
      * @param int $width
+     *
      * @return $this
      */
-    public function composite(Sparkline $chart)
+    public function composite(self $chart)
     {
         $options = $chart->getOptions();
 
@@ -156,11 +160,12 @@ class Sparkline extends Widget
      * Setup scripts.
      *
      * @param int $width
+     *
      * @return string
      */
     protected function script()
     {
-        $values  = json_encode($this->values);
+        $values = json_encode($this->values);
         $options = json_encode($this->options);
 
         $combos = '';
@@ -207,6 +212,7 @@ JS
         ]);
 
         $this->collectAssets();
+
         return <<<HTML
 <span {$this->formatHtmlAttributes()}></span>
 HTML;
@@ -226,7 +232,8 @@ HTML;
 
     /**
      * @param string $method
-     * @param array $parameters
+     * @param array  $parameters
+     *
      * @return Sparkline|Widget
      */
     public function __call($method, $parameters)
@@ -238,7 +245,6 @@ HTML;
         return parent::__call($method, $parameters); // TODO: Change the autogenerated stub
     }
 
-
     /**
      * Make element id.
      *
@@ -255,8 +261,9 @@ HTML;
     /**
      * Return JsonResponse instance.
      *
-     * @param bool $returnOptions
+     * @param bool  $returnOptions
      * @param array $data
+     *
      * @return \Illuminate\Http\JsonResponse
      */
     public function toJsonResponse(bool $returnOptions = true, array $data = [])

+ 1 - 0
src/Widgets/Tab.php

@@ -47,6 +47,7 @@ class Tab extends Widget
      * Set style.
      *
      * @param string $style
+     *
      * @return $this
      */
     public function style($style)

+ 3 - 2
src/Widgets/Table.php

@@ -44,7 +44,7 @@ class Table extends Widget
         $this->setRows($rows);
         $this->setStyle($style);
 
-        $this->class('table '.implode(' ', (array)$this->style), true);
+        $this->class('table '.implode(' ', (array) $this->style), true);
     }
 
     /**
@@ -63,6 +63,7 @@ class Table extends Widget
 
     /**
      * @param int $depth
+     *
      * @return $this
      */
     public function depth(int $depth)
@@ -81,7 +82,7 @@ class Table extends Widget
      */
     public function setRows($rows = [])
     {
-        if (! Arr::isAssoc($rows)) {
+        if (!Arr::isAssoc($rows)) {
             $this->rows = $rows;
 
             return $this;

+ 3 - 2
src/Widgets/Terminal.php

@@ -21,12 +21,13 @@ class Terminal extends Widget
 
     /**
      * @param string $command
-     * @param array $parameters
+     * @param array  $parameters
+     *
      * @return static
      */
     public static function call(string $command, array $parameters = [])
     {
-        $output = new StringOutput;
+        $output = new StringOutput();
         Artisan::call($command, $parameters, $output);
 
         return static::make($output);

+ 6 - 0
src/Widgets/Tooltip.php

@@ -27,6 +27,7 @@ class Tooltip extends Widget
 
     /**
      * @param $selector
+     *
      * @return $this
      */
     public function selector($selector)
@@ -40,6 +41,7 @@ class Tooltip extends Widget
      * Set max width for tooltip.
      *
      * @param string $width
+     *
      * @return $this
      */
     public function maxWidth(string $width)
@@ -53,6 +55,7 @@ class Tooltip extends Widget
      * Set tooltip content.
      *
      * @param $content
+     *
      * @return $this
      */
     public function content($content)
@@ -66,11 +69,13 @@ class Tooltip extends Widget
      * Set the backgroud of tooltip.
      *
      * @param string $color
+     *
      * @return $this
      */
     public function background(string $color)
     {
         $this->bg = $color;
+
         return $this;
     }
 
@@ -138,6 +143,7 @@ class Tooltip extends Widget
      * How to position the tooltip - top | bottom | left | right.
      *
      * @param string $val
+     *
      * @return $this
      */
     public function placement(string $val = 'left')

+ 17 - 16
src/Widgets/Tree.php

@@ -12,11 +12,11 @@ class Tree extends Widget
 
     protected $options = [
         'plugins' => ['checkbox', 'types'],
-        'core' => [
+        'core'    => [
             'check_callback' => true,
 
             'themes' => [
-                'name' => 'proton',
+                'name'       => 'proton',
                 'responsive' => true,
             ],
         ],
@@ -62,7 +62,7 @@ class Tree extends Widget
         if ($value instanceof Arrayable) {
             $value = $value->toArray();
         }
-        $this->value = (array)$value;
+        $this->value = (array) $value;
 
         return $this;
     }
@@ -71,12 +71,13 @@ class Tree extends Widget
      * @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;
@@ -84,14 +85,14 @@ class Tree extends Widget
 
     /**
      * @param array $data exp:
-     *     {
-     *          "id": "1",
-     *          "parent": "#",
-     *          "text": "Dashboard",
-     *          // "state": {"selected": true}
-     *     }
-     *
+     *                    {
+     *                    "id": "1",
+     *                    "parent": "#",
+     *                    "text": "Dashboard",
+     *                    // "state": {"selected": true}
+     *                    }
      * @param array $data
+     *
      * @return $this
      */
     public function nodes($data)
@@ -106,7 +107,7 @@ class Tree extends Widget
 
     public function render()
     {
-        $id = 'widget-tree-' . Str::random(8);
+        $id = 'widget-tree-'.Str::random(8);
 
         $this->id($id);
         $this->class('jstree-wrapper');
@@ -128,14 +129,14 @@ class Tree extends Widget
         if ($value && !is_array($value)) {
             $value = explode(',', $value);
         }
-        $value = (array)$value;
+        $value = (array) $value;
 
         if (!$this->nodes) {
             return;
         }
 
-        $idColumn     = $this->columnNames['id'];
-        $textColumn   = $this->columnNames['text'];
+        $idColumn = $this->columnNames['id'];
+        $textColumn = $this->columnNames['text'];
         $parentColumn = $this->columnNames['parent'];
 
         $nodes = [];

+ 11 - 6
src/Widgets/Widget.php

@@ -51,6 +51,7 @@ abstract class Widget implements Renderable
      * Create a widget instance.
      *
      * @param mixed ...$params
+     *
      * @return static
      */
     public static function make(...$params)
@@ -59,8 +60,8 @@ abstract class Widget implements Renderable
     }
 
     /**
-     *
      * @param array $options
+     *
      * @return $this
      */
     public function options($options = [])
@@ -107,6 +108,7 @@ abstract class Widget implements Renderable
      * To string.
      *
      * @param $value
+     *
      * @return string
      */
     protected function toString($value)
@@ -145,12 +147,13 @@ abstract class Widget implements Renderable
     /**
      * @param $method
      * @param $parameters
+     *
      * @return $this
      */
     public function __call($method, $parameters)
     {
         if ($method === 'style' || $method === 'class') {
-            $value  = $parameters[0] ?? null;
+            $value = $parameters[0] ?? null;
             $append = $parameters[1] ?? ($method === 'class' ? false : true);
 
             if ($append) {
@@ -158,7 +161,7 @@ abstract class Widget implements Renderable
 
                 $de = $method === 'style' ? ';' : ' ';
 
-                $value = $original . $de . $value;
+                $value = $original.$de.$value;
             }
 
             return $this->setHtmlAttribute($method, $value);
@@ -170,7 +173,8 @@ abstract class Widget implements Renderable
     }
 
     /**
-     * @param  string  $key
+     * @param string $key
+     *
      * @return mixed
      */
     public function __get($key)
@@ -179,8 +183,9 @@ abstract class Widget implements Renderable
     }
 
     /**
-     * @param  string  $key
-     * @param  mixed   $value
+     * @param string $key
+     * @param mixed  $value
+     *
      * @return void
      */
     public function __set($key, $value)

+ 2 - 2
tests/Controllers/DropdownController.php

@@ -6,7 +6,6 @@ use Dcat\Admin\Admin;
 use Dcat\Admin\Layout\Content;
 use Dcat\Admin\Layout\Row;
 use Dcat\Admin\Widgets\Box;
-use Dcat\Admin\Widgets\Code;
 use Dcat\Admin\Widgets\Dropdown;
 use Illuminate\Routing\Controller;
 
@@ -52,6 +51,7 @@ class DropdownController extends Controller
                 $this->divider();
             }
             $k++;
+
             return "{$k}. $v";
         });
 
@@ -74,7 +74,7 @@ class DropdownController extends Controller
             });
 
         Admin::script(
-            <<<JS
+            <<<'JS'
 $('.test_item').click(function () {
     LA.info("Selected: " + JSON.stringify($(this).data()));
 });

+ 1 - 1
tests/Controllers/ReportController.php

@@ -17,7 +17,7 @@ class ReportController extends Controller
 
     protected function grid()
     {
-        $grid = new Grid(new Report);
+        $grid = new Grid(new Report());
 
         // 开启responsive插件
         $grid->responsive();

Some files were not shown because too many files changed in this diff