jqh %!s(int64=6) %!d(string=hai) anos
pai
achega
c754f91fd0

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

@@ -1,4 +1,4 @@
-@if ($grid->allowHeader())
+@if ($grid->allowToolbar())
     <div class="box-header " >
         @if(!empty($title))
             <h4 class="pull-left" style="margin:5px 10px 0;">

+ 4 - 4
src/Form.php

@@ -8,7 +8,7 @@ use Dcat\Admin\Form\Field;
 use Dcat\Admin\Form\Row;
 use Dcat\Admin\Form\Tab;
 use Dcat\Admin\Contracts\Repository;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Dcat\Admin\Widgets\DialogForm;
 use Illuminate\Contracts\Support\MessageProvider;
 use Illuminate\Contracts\Support\Renderable;
@@ -83,9 +83,9 @@ use Dcat\Admin\Form\Concerns;
  */
 class Form implements Renderable
 {
-    use BuilderEvents,
-        Concerns\Events,
-        Concerns\Files,
+    use HasBuilderEvents,
+        Concerns\HasEvents,
+        Concerns\HasFiles,
         Macroable {
             __call as macroCall;
         }

+ 1 - 1
src/Form/Concerns/Events.php → src/Form/Concerns/HasEvents.php

@@ -6,7 +6,7 @@ use Closure;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Response;
 
-trait Events
+trait HasEvents
 {
     /**
      * @var array

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

@@ -10,7 +10,7 @@ use Illuminate\Support\Str;
 /**
  * @property Form $form
  */
-trait FieldValidator
+trait HasFieldValidator
 {
     /**
      * The validation rules for creation.

+ 1 - 1
src/Form/Concerns/Files.php → src/Form/Concerns/HasFiles.php

@@ -6,7 +6,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
 use Illuminate\Support\Facades\Input;
 use Dcat\Admin\Form\Field;
 
-trait Files
+trait HasFiles
 {
     /**
      * @param array $data

+ 2 - 1
src/Form/Field.php

@@ -16,7 +16,8 @@ use Illuminate\Support\Traits\Macroable;
  */
 class Field implements Renderable
 {
-    use Macroable, Concerns\FieldValidator;
+    use Macroable,
+        Concerns\HasFieldValidator;
 
     const FILE_DELETE_FLAG = '_file_del_';
 

+ 179 - 420
src/Grid.php

@@ -5,9 +5,6 @@ namespace Dcat\Admin;
 use Closure;
 use Dcat\Admin\Grid\Column;
 use Dcat\Admin\Grid\Displayers;
-use Dcat\Admin\Grid\Exporter;
-use Dcat\Admin\Grid\Exporters\AbstractExporter;
-use Dcat\Admin\Grid\Filter;
 use Dcat\Admin\Grid\Model;
 use Dcat\Admin\Grid\Responsive;
 use Dcat\Admin\Grid\Row;
@@ -15,22 +12,24 @@ use Dcat\Admin\Grid\Tools;
 use Dcat\Admin\Grid\Concerns;
 use Dcat\Admin\Contracts\Repository;
 use Dcat\Admin\Support\Helper;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Support\Traits\Macroable;
 use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Collection;
-use Illuminate\Support\Facades\Input;
 use Illuminate\Support\Str;
 
 class Grid
 {
-    use BuilderEvents,
+    use HasBuilderEvents,
         Concerns\HasElementNames,
-        Concerns\Actions,
-        Concerns\Options,
-        Concerns\MultipleHeader,
-        Concerns\QuickSearch,
+        Concerns\HasFilter,
+        Concerns\HasTools,
+        Concerns\HasActions,
+        Concerns\HasPaginator,
+        Concerns\HasExporter,
+        Concerns\HasMultipleHeader,
+        Concerns\HasQuickSearch,
         Macroable {
             __call as macroCall;
         }
@@ -91,13 +90,6 @@ class Grid
      */
     protected $variables = [];
 
-    /**
-     * The grid Filter.
-     *
-     * @var \Dcat\Admin\Grid\Filter
-     */
-    protected $filter;
-
     /**
      * Resource path of the grid.
      *
@@ -112,13 +104,6 @@ class Grid
      */
     protected $keyName = 'id';
 
-    /**
-     * Export driver.
-     *
-     * @var string
-     */
-    protected $exporter;
-
     /**
      * View for grid to render.
      *
@@ -126,27 +111,6 @@ class Grid
      */
     protected $view = 'admin::grid.table';
 
-    /**
-     * Per-page options.
-     *
-     * @var array
-     */
-    protected $perPages = [10, 20, 30, 50, 100, 200];
-
-    /**
-     * Default items count per-page.
-     *
-     * @var int
-     */
-    protected $perPage = 20;
-
-    /**
-     * Header tools.
-     *
-     * @var Tools
-     */
-    protected $tools;
-
     /**
      * @var Closure
      */
@@ -177,6 +141,42 @@ class Grid
      */
     protected $tableId;
 
+    /**
+     * Options for grid.
+     *
+     * @var array
+     */
+    protected $options = [
+        'show_pagination'        => true,
+        'show_filter'            => true,
+        'show_actions'           => true,
+        'show_quick_edit_button' => true,
+        'show_edit_button'       => true,
+        'show_view_button'       => true,
+        'show_delete_button'     => true,
+        'show_row_selector'      => true,
+        'show_create_btn'        => true,
+        'show_quick_create_btn'  => true,
+        'show_bordered'          => false,
+        'show_toolbar'           => true,
+
+        'row_selector_style'      => 'primary',
+        'row_selector_circle'     => true,
+        'row_selector_clicktr'    => false,
+        'row_selector_label_name' => null,
+        'row_selector_bg'         => 'var(--20)',
+
+        'show_exporter'             => false,
+        'show_export_all'           => true,
+        'show_export_current_page'  => true,
+        'show_export_selected_rows' => true,
+        'export_limit'              => 50000,
+
+        'dialog_form_area'   => ['700px', '670px'],
+        'table_header_style' => 'table-header-gray',
+
+    ];
+
     /**
      * Create a new grid instance.
      *
@@ -203,32 +203,8 @@ class Grid
     }
 
     /**
-     * Create a grid instance.
-     *
-     * @param mixed ...$params
-     * @return $this
-     */
-    public static function make(...$params)
-    {
-        return new static(...$params);
-    }
-
-    /**
-     * Enable responsive tables.
-     * @see https://github.com/nadangergeo/RWD-Table-Patterns
+     * Get table ID.
      *
-     * @return Responsive
-     */
-    public function responsive()
-    {
-        if (!$this->responsive) {
-            $this->responsive = new Responsive($this);
-        }
-
-        return $this->responsive;
-    }
-
-    /**
      * @return string
      */
     public function getTableId()
@@ -236,92 +212,6 @@ class Grid
         return $this->tableId;
     }
 
-    /**
-     * @return bool
-     */
-    public function allowResponsive()
-    {
-        return $this->responsive ? true : false;
-    }
-
-    /**
-     * @return bool
-     */
-    public function allowHeader()
-    {
-        if (
-            $this->option('show_toolbar')
-            && (
-                $this->getTools()->has() ||
-                $this->allowExportBtn() ||
-                $this->allowCreateBtn() ||
-                $this->allowQuickCreateBtn() ||
-                $this->allowResponsive() ||
-                !empty($this->variables['title'])
-            )
-        ) {
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Setup grid tools.
-     */
-    public function setupTools()
-    {
-        $this->tools = new Tools($this);
-    }
-
-    /**
-     * Setup grid filter.
-     *
-     * @return void
-     */
-    protected function setupFilter()
-    {
-        $this->filter = new Filter($this->model());
-    }
-
-    /**
-     * Handle export request.
-     *
-     * @param bool $forceExport
-     */
-    protected function handleExportRequest($forceExport = false)
-    {
-        if (!$scope = request(Exporter::$queryName)) {
-            return;
-        }
-
-        // clear output buffer.
-        if (ob_get_length()) {
-            ob_end_clean();
-        }
-
-        $this->model()->usePaginate(false);
-
-        if ($this->builder) {
-            call_user_func($this->builder, $this);
-
-            $this->getExporter($scope)->export();
-        }
-
-        if ($forceExport) {
-            $this->getExporter($scope)->export();
-        }
-    }
-
-    /**
-     * @param string $scope
-     *
-     * @return AbstractExporter
-     */
-    protected function getExporter($scope)
-    {
-        return (new Exporter($this))->resolve($this->exporter)->withScope($scope);
-    }
 
     /**
      * Get primary key name of model.
@@ -469,74 +359,6 @@ class Grid
         return $this->columnNames;
     }
 
-    /**
-     * Paginate the grid.
-     *
-     * @param int $perPage
-     *
-     * @return void
-     */
-    public function paginate(int $perPage = 20)
-    {
-        $this->perPage = $perPage;
-
-        $this->model()->setPerPage($perPage);
-    }
-
-    /**
-     * @return int
-     */
-    public function getPerPage()
-    {
-        return $this->perPage;
-    }
-
-    /**
-     * Get the grid paginator.
-     *
-     * @return mixed
-     */
-    public function paginator()
-    {
-        if (!$this->options['show_pagination']) {
-            return;
-        }
-
-        return new Tools\Paginator($this);
-    }
-
-    /**
-     * If this grid use pagination.
-     *
-     * @return bool
-     */
-    public function allowPagination()
-    {
-        return $this->options['show_pagination'];
-    }
-
-    /**
-     * Set per-page options.
-     *
-     * @param array $perPages
-     */
-    public function perPages(array $perPages)
-    {
-        $this->perPages = $perPages;
-
-        return $this;
-    }
-
-    /**
-     * Get per-page options.
-     *
-     * @return array
-     */
-    public function getPerPages()
-    {
-        return $this->perPages;
-    }
-
     /**
      * @param array $options
      * @return $this
@@ -638,79 +460,6 @@ HTML
         $this->sortHeaders();
     }
 
-    /**
-     * @return Tools
-     */
-    public function getTools()
-    {
-        return $this->tools;
-    }
-
-    /**
-     * Get filter of Grid.
-     *
-     * @return Filter
-     */
-    public function getFilter()
-    {
-        return $this->filter;
-    }
-
-    /**
-     * Process the grid filter.
-     *
-     * @param bool $toArray
-     *
-     * @return array|Collection|mixed
-     */
-    public function processFilter($toArray = true)
-    {
-        if ($this->builder) {
-            call_user_func($this->builder, $this);
-        }
-
-        return $this->filter->execute($toArray);
-    }
-
-    /**
-     * Set the grid filter.
-     *
-     * @param Closure $callback
-     * @return $this
-     */
-    public function filter(Closure $callback)
-    {
-        call_user_func($callback, $this->filter);
-
-        return $this;
-    }
-
-    /**
-     * Render the grid filter.
-     *
-     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
-     */
-    public function renderFilter()
-    {
-        if (!$this->options['show_filter']) {
-            return '';
-        }
-
-        return $this->filter->render();
-    }
-
-    /**
-     * Expand filter.
-     *
-     * @return $this
-     */
-    public function expandFilter()
-    {
-        $this->filter->expand();
-
-        return $this;
-    }
-
     /**
      * Build the grid rows.
      *
@@ -747,63 +496,6 @@ HTML
         $this->rowsCallback[] = $callable;
     }
 
-    /**
-     * Setup grid tools.
-     *
-     * @param Closure $callback
-     *
-     * @return $this
-     */
-    public function tools(Closure $callback)
-    {
-        call_user_func($callback, $this->tools);
-
-        return $this;
-    }
-
-    /**
-     * Render custom tools.
-     *
-     * @return string
-     */
-    public function renderTools()
-    {
-        return $this->tools->render();
-    }
-
-    /**
-     * Set exporter driver for Grid to export.
-     *
-     * @param $exporter
-     *
-     * @return $this
-     */
-    public function exporter($exporter)
-    {
-        $this->exporter = $exporter;
-
-        return $this;
-    }
-
-    /**
-     * Get the export url.
-     *
-     * @param int  $scope
-     * @param null $args
-     *
-     * @return string
-     */
-    public function getExportUrl($scope = 1, $args = null)
-    {
-        $input = array_merge(Input::all(), Exporter::formatExportQuery($scope, $args));
-
-        if ($constraints = $this->model()->getConstraints()) {
-            $input = array_merge($input, $constraints);
-        }
-
-        return $this->getResource().'?'.http_build_query($input);
-    }
-
     /**
      * Get create url.
      *
@@ -835,72 +527,6 @@ HTML
         return $this;
     }
 
-    /**
-     * If grid show export btn.
-     *
-     * @return bool
-     */
-    public function allowExportBtn()
-    {
-        return $this->options['show_exporter'];
-    }
-
-    /**
-     * @param array $options
-     * @return $this
-     */
-    public function setExportOptions(array $options)
-    {
-        if (isset($options['limit'])) {
-            $this->options['export_limit'] = $options['limit'];
-        }
-
-        if (isset($options['all'])) {
-            $this->options['show_export_all'] = $options['show_all'];
-        }
-
-        if (isset($options['current_page'])) {
-            $this->options['show_export_current_page'] = $options['current_page'];
-        }
-
-        if (isset($options['selected_rows'])) {
-            $this->options['show_export_selected_rows'] = $options['selected_rows'];
-        }
-
-        return $this;
-    }
-
-    /**
-     * Render export button.
-     *
-     * @return string
-     */
-    public function renderExportButton()
-    {
-        if (!$this->options['show_exporter']) {
-            return '';
-        }
-        return (new Tools\ExportButton($this))->render();
-    }
-
-    /**
-     * If allow creation.
-     *
-     * @return bool
-     */
-    public function allowCreateBtn()
-    {
-        return $this->options['show_create_btn'];
-    }
-
-    /**
-     * @return bool
-     */
-    public function allowQuickCreateBtn()
-    {
-        return $this->options['show_quick_create_btn'];
-    }
-
     /**
      * Render create button for grid.
      *
@@ -1019,6 +645,105 @@ HTML;
 HTML;
     }
 
+    /**
+     * Get or set option for grid.
+     *
+     * @param string $key
+     * @param mixed  $value
+     *
+     * @return $this|mixed
+     */
+    public function option($key, $value = null)
+    {
+        if (is_null($value)) {
+            return $this->options[$key];
+        }
+
+        $this->options[$key] = $value;
+
+        return $this;
+    }
+
+    /**
+     * Disable row selector.
+     *
+     * @return $this
+     */
+    public function disableRowSelector(bool $disable = true)
+    {
+        $this->tools->disableBatchActions($disable);
+
+        return $this->option('show_row_selector', !$disable);
+    }
+
+    /**
+     * Show row selector.
+     *
+     * @return $this
+     */
+    public function showRowSelector(bool $val = true)
+    {
+        return $this->disableRowSelector(!$val);
+    }
+
+    /**
+     * Remove create button on grid.
+     *
+     * @return $this
+     */
+    public function disableCreateButton(bool $disable = true)
+    {
+        return $this->option('show_create_btn', !$disable);
+    }
+
+    /**
+     * Show create button.
+     *
+     * @return $this
+     */
+    public function showCreateButton(bool $val = true)
+    {
+        return $this->disableCreateButton(!$val);
+    }
+
+    /**
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableQuickCreateButton(bool $disable = true)
+    {
+        return $this->option('show_quick_create_btn', !$disable);
+    }
+
+    /**
+     * @param bool $val
+     * @return $this
+     */
+    public function showQuickCreateButton(bool $val = true)
+    {
+        return $this->disableQuickCreateButton(!$val);
+    }
+
+    /**
+     * If allow creation.
+     *
+     * @return bool
+     */
+    public function allowCreateBtn()
+    {
+        return $this->options['show_create_btn'];
+    }
+
+    /**
+     * If grid show quick create button.
+     *
+     * @return bool
+     */
+    public function allowQuickCreateBtn()
+    {
+        return $this->options['show_quick_create_btn'];
+    }
+
     /**
      * Set resource path.
      *
@@ -1045,6 +770,40 @@ HTML;
         );
     }
 
+    /**
+     * Create a grid instance.
+     *
+     * @param mixed ...$params
+     * @return $this
+     */
+    public static function make(...$params)
+    {
+        return new static(...$params);
+    }
+
+    /**
+     * Enable responsive tables.
+     * @see https://github.com/nadangergeo/RWD-Table-Patterns
+     *
+     * @return Responsive
+     */
+    public function responsive()
+    {
+        if (!$this->responsive) {
+            $this->responsive = new Responsive($this);
+        }
+
+        return $this->responsive;
+    }
+
+    /**
+     * @return bool
+     */
+    public function allowResponsive()
+    {
+        return $this->responsive ? true : false;
+    }
+
     /**
      * @param Closure $closure
      * @return $this;

+ 5 - 5
src/Grid/Column.php

@@ -5,8 +5,8 @@ namespace Dcat\Admin\Grid;
 use Closure;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Grid\Displayers\AbstractDisplayer;
-use Dcat\Admin\Traits\BuilderEvents;
-use Dcat\Admin\Traits\Definitions;
+use Dcat\Admin\Traits\HasBuilderEvents;
+use Dcat\Admin\Traits\HasDefinitions;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Arr;
@@ -52,10 +52,10 @@ use Illuminate\Support\Str;
  */
 class Column
 {
-    use BuilderEvents,
-        Definitions,
+    use HasBuilderEvents,
+        HasDefinitions,
         Grid\Column\HasHeader,
-        Grid\Column\Displayers;
+        Grid\Column\HasDisplayers;
 
     const SELECT_COLUMN_NAME = '__row_selector__';
 

+ 1 - 1
src/Grid/Column/Displayers.php → src/Grid/Column/HasDisplayers.php

@@ -8,7 +8,7 @@ use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Support\Arr;
 use Illuminate\Support\Collection;
 
-trait Displayers
+trait HasDisplayers
 {
     /**
      * Display using display abstract.

+ 0 - 87
src/Grid/Concerns/Actions.php

@@ -1,87 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Grid\Concerns;
-
-use Closure;
-use Dcat\Admin\Grid;
-use Dcat\Admin\Grid\Displayers;
-
-trait Actions
-{
-    /**
-     * Callback for grid actions.
-     *
-     * @var Closure[]
-     */
-    protected $actionsCallback = [];
-
-    /**
-     * Actions column display class.
-     *
-     * @var string
-     */
-    protected $actionsClass;
-
-    /**
-     * @param string $actionClass
-     *
-     * @return $this
-     */
-    public function setActionClass(string $actionClass)
-    {
-        if (is_subclass_of($actionClass, Grid\Displayers\Actions::class)) {
-            $this->actionsClass = $actionClass;
-        }
-
-        return $this;
-    }
-
-
-    /**
-     * Get action display class.
-     *
-     * @return \Illuminate\Config\Repository|mixed|string
-     */
-    public function getActionClass()
-    {
-        if ($this->actionsClass) {
-            return $this->actionsClass;
-        }
-
-        if ($class = config('admin.grid.grid_action_class')) {
-            return $class;
-        }
-
-        return Grid\Displayers\Actions::class;
-    }
-
-
-    /**
-     * Set grid action callback.
-     *
-     * @param Closure $callback
-     *
-     * @return $this
-     */
-    public function actions(Closure $callback)
-    {
-        $this->actionsCallback[] = $callback;
-
-        return $this;
-    }
-
-    /**
-     * Add `actions` column for grid.
-     *
-     * @return void
-     */
-    protected function appendActionsColumn()
-    {
-        if (!$this->options['show_actions']) {
-            return;
-        }
-
-        $this->addColumn('__actions__', trans('admin.action'))
-            ->displayUsing($this->getActionClass(), [$this->actionsCallback]);
-    }
-}

+ 202 - 0
src/Grid/Concerns/HasActions.php

@@ -0,0 +1,202 @@
+<?php
+
+namespace Dcat\Admin\Grid\Concerns;
+
+use Closure;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Grid\Displayers;
+
+trait HasActions
+{
+    /**
+     * Callback for grid actions.
+     *
+     * @var Closure[]
+     */
+    protected $actionsCallback = [];
+
+    /**
+     * Actions column display class.
+     *
+     * @var string
+     */
+    protected $actionsClass;
+
+    /**
+     * @param string $actionClass
+     *
+     * @return $this
+     */
+    public function setActionClass(string $actionClass)
+    {
+        if (is_subclass_of($actionClass, Grid\Displayers\Actions::class)) {
+            $this->actionsClass = $actionClass;
+        }
+
+        return $this;
+    }
+
+
+    /**
+     * Get action display class.
+     *
+     * @return \Illuminate\Config\Repository|mixed|string
+     */
+    public function getActionClass()
+    {
+        if ($this->actionsClass) {
+            return $this->actionsClass;
+        }
+
+        if ($class = config('admin.grid.grid_action_class')) {
+            return $class;
+        }
+
+        return Grid\Displayers\Actions::class;
+    }
+
+
+    /**
+     * Set grid action callback.
+     *
+     * @param Closure $callback
+     *
+     * @return $this
+     */
+    public function actions(Closure $callback)
+    {
+        $this->actionsCallback[] = $callback;
+
+        return $this;
+    }
+
+    /**
+     * Add `actions` column for grid.
+     *
+     * @return void
+     */
+    protected function appendActionsColumn()
+    {
+        if (!$this->options['show_actions']) {
+            return;
+        }
+
+        $this->addColumn('__actions__', trans('admin.action'))
+            ->displayUsing($this->getActionClass(), [$this->actionsCallback]);
+    }
+
+    /**
+     * Disable all actions.
+     *
+     * @return $this
+     */
+    public function disableActions(bool $disable = true)
+    {
+        return $this->option('show_actions', !$disable);
+    }
+
+    /**
+     * Show all actions.
+     *
+     * @return $this
+     */
+    public function showActions(bool $val = true)
+    {
+        return $this->disableActions(!$val);
+    }
+
+    /**
+     * Disable edit.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableEditButton(bool $disable = true)
+    {
+        $this->options['show_edit_button'] = !$disable;
+
+        return $this;
+    }
+
+    /**
+     * Show edit.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showEditButton(bool $val = true)
+    {
+        return $this->disableEditButton(!$val);
+    }
+
+    /**
+     * Disable quick edit.
+     *
+     * @return $this.
+     */
+    public function disableQuickEditButton(bool $disable = true)
+    {
+        $this->options['show_quick_edit_button'] = !$disable;
+
+        return $this;
+    }
+
+    /**
+     * Show quick edit button.
+     *
+     * @return $this.
+     */
+    public function showQuickEditButton(bool $val = true)
+    {
+        return $this->disableQuickEditButton(!$val);
+    }
+
+    /**
+     * Disable view action.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableViewButton(bool $disable = true)
+    {
+        $this->options['show_view_button'] = !$disable;
+
+        return $this;
+    }
+
+    /**
+     * Show view action.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function showViewButton(bool $val = true)
+    {
+        return $this->disableViewButton(!$val);
+    }
+
+    /**
+     * Disable delete.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableDeleteButton(bool $disable = true)
+    {
+        $this->options['show_delete_button'] = !$disable;
+
+        return $this;
+    }
+
+    /**
+     * Show delete button.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function showDeleteButton(bool $val = true)
+    {
+        return $this->disableDeleteButton(!$val);
+    }
+
+}

+ 161 - 0
src/Grid/Concerns/HasExporter.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace Dcat\Admin\Grid\Concerns;
+
+use Dcat\Admin\Grid\Exporter;
+use Dcat\Admin\Grid\Exporters\AbstractExporter;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Grid\Tools;
+use Illuminate\Support\Facades\Input;
+
+trait HasExporter
+{
+    /**
+     * Export driver.
+     *
+     * @var string|Grid\Exporters\AbstractExporter
+     */
+    protected $exporter;
+
+    /**
+     * Set exporter driver for Grid to export.
+     *
+     * @param string|Grid\Exporters\AbstractExporter $exporter
+     *
+     * @return $this
+     */
+    public function exporter($exporter)
+    {
+        $this->exporter = $exporter;
+
+        return $this;
+    }
+
+    /**
+     * Handle export request.
+     *
+     * @param bool $forceExport
+     */
+    protected function handleExportRequest($forceExport = false)
+    {
+        if (!$scope = request(Exporter::$queryName)) {
+            return;
+        }
+
+        // clear output buffer.
+        if (ob_get_length()) {
+            ob_end_clean();
+        }
+
+        $this->model()->usePaginate(false);
+
+        if ($this->builder) {
+            call_user_func($this->builder, $this);
+
+            $this->getExporter($scope)->export();
+        }
+
+        if ($forceExport) {
+            $this->getExporter($scope)->export();
+        }
+    }
+
+    /**
+     * @param string $scope
+     *
+     * @return AbstractExporter
+     */
+    protected function getExporter($scope)
+    {
+        return (new Exporter($this))->resolve($this->exporter)->withScope($scope);
+    }
+
+
+    /**
+     * Get the export url.
+     *
+     * @param int  $scope
+     * @param null $args
+     *
+     * @return string
+     */
+    public function getExportUrl($scope = 1, $args = null)
+    {
+        $input = array_merge(Input::all(), Exporter::formatExportQuery($scope, $args));
+
+        if ($constraints = $this->model()->getConstraints()) {
+            $input = array_merge($input, $constraints);
+        }
+
+        return $this->getResource().'?'.http_build_query($input);
+    }
+
+    /**
+     * @param array $options
+     * @return $this
+     */
+    public function setExportOptions(array $options)
+    {
+        if (isset($options['limit'])) {
+            $this->options['export_limit'] = $options['limit'];
+        }
+
+        if (isset($options['all'])) {
+            $this->options['show_export_all'] = $options['show_all'];
+        }
+
+        if (isset($options['current_page'])) {
+            $this->options['show_export_current_page'] = $options['current_page'];
+        }
+
+        if (isset($options['selected_rows'])) {
+            $this->options['show_export_selected_rows'] = $options['selected_rows'];
+        }
+
+        return $this;
+    }
+
+    /**
+     * Render export button.
+     *
+     * @return string
+     */
+    public function renderExportButton()
+    {
+        if (!$this->options['show_exporter']) {
+            return '';
+        }
+        return (new Tools\ExportButton($this))->render();
+    }
+
+    /**
+     * Disable export.
+     *
+     * @return $this
+     */
+    public function disableExporter(bool $disable = true)
+    {
+        return $this->option('show_exporter', !$disable);
+    }
+
+    /**
+     * Show export button.
+     *
+     * @return $this
+     */
+    public function showExporter(bool $val = true)
+    {
+        return $this->disableExporter(!$val);
+    }
+
+    /**
+     * If grid show export btn.
+     *
+     * @return bool
+     */
+    public function allowExportBtn()
+    {
+        return $this->options['show_exporter'];
+    }
+
+}

+ 140 - 0
src/Grid/Concerns/HasFilter.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace Dcat\Admin\Grid\Concerns;
+
+use Closure;
+use Dcat\Admin\Grid;
+use Illuminate\Support\Collection;
+
+trait HasFilter
+{
+    /**
+     * The grid Filter.
+     *
+     * @var Grid\Filter
+     */
+    protected $filter;
+
+    /**
+     * Setup grid filter.
+     *
+     * @return void
+     */
+    protected function setupFilter()
+    {
+        $this->filter = new Grid\Filter($this->model());
+    }
+
+    /**
+     * Get filter of Grid.
+     *
+     * @return Grid\Filter
+     */
+    public function getFilter()
+    {
+        return $this->filter;
+    }
+
+    /**
+     * Process the grid filter.
+     *
+     * @param bool $toArray
+     *
+     * @return array|Collection|mixed
+     */
+    public function processFilter($toArray = true)
+    {
+        if ($this->builder) {
+            call_user_func($this->builder, $this);
+        }
+
+        return $this->filter->execute($toArray);
+    }
+
+    /**
+     * Set the grid filter.
+     *
+     * @param Closure $callback
+     * @return $this
+     */
+    public function filter(Closure $callback)
+    {
+        call_user_func($callback, $this->filter);
+
+        return $this;
+    }
+
+    /**
+     * Render the grid filter.
+     *
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
+     */
+    public function renderFilter()
+    {
+        if (!$this->options['show_filter']) {
+            return '';
+        }
+
+        return $this->filter->render();
+    }
+
+    /**
+     * Expand filter.
+     *
+     * @return $this
+     */
+    public function expandFilter()
+    {
+        $this->filter->expand();
+
+        return $this;
+    }
+
+    /**
+     * Disable grid filter.
+     *
+     * @return $this
+     */
+    public function disableFilter(bool $disable = true)
+    {
+//        $this->tools->disableFilterButton($disable);
+        $this->filter->disableCollapse($disable);
+
+        return $this->option('show_filter', !$disable);
+    }
+
+    /**
+     * Show grid filter.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showFilter(bool $val = true)
+    {
+        return $this->disableFilter(!$val);
+    }
+
+    /**
+     * Disable filter button.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableFilterButton(bool $disable = true)
+    {
+        $this->tools->disableFilterButton($disable);
+
+        return $this;
+    }
+
+    /**
+     * Show filter button.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showFilterButton(bool $val = true)
+    {
+        return $this->disableFilterButton(!$val);
+    }
+}

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

@@ -5,7 +5,7 @@ namespace Dcat\Admin\Grid\Concerns;
 use Dcat\Admin\Grid\Column;
 use Dcat\Admin\Grid\Header;
 
-trait MultipleHeader
+trait HasMultipleHeader
 {
     /**
      * Table multiple headers.

+ 114 - 0
src/Grid/Concerns/HasPaginator.php

@@ -0,0 +1,114 @@
+<?php
+
+namespace Dcat\Admin\Grid\Concerns;
+
+use Dcat\Admin\Grid\Tools;
+
+trait HasPaginator
+{
+    /**
+     * Per-page options.
+     *
+     * @var array
+     */
+    protected $perPages = [10, 20, 30, 50, 100, 200];
+
+    /**
+     * Default items count per-page.
+     *
+     * @var int
+     */
+    protected $perPage = 20;
+
+    /**
+     * Paginate the grid.
+     *
+     * @param int $perPage
+     *
+     * @return void
+     */
+    public function paginate(int $perPage = 20)
+    {
+        $this->perPage = $perPage;
+
+        $this->model()->setPerPage($perPage);
+    }
+
+    /**
+     * @return int
+     */
+    public function getPerPage()
+    {
+        return $this->perPage;
+    }
+
+    /**
+     * Get the grid paginator.
+     *
+     * @return mixed
+     */
+    public function paginator()
+    {
+        if (!$this->options['show_pagination']) {
+            return;
+        }
+
+        return new Tools\Paginator($this);
+    }
+
+    /**
+     * If this grid use pagination.
+     *
+     * @return bool
+     */
+    public function allowPagination()
+    {
+        return $this->options['show_pagination'];
+    }
+
+    /**
+     * Set per-page options.
+     *
+     * @param array $perPages
+     */
+    public function perPages(array $perPages)
+    {
+        $this->perPages = $perPages;
+
+        return $this;
+    }
+
+    /**
+     * Get per-page options.
+     *
+     * @return array
+     */
+    public function getPerPages()
+    {
+        return $this->perPages;
+    }
+
+    /**
+     * Disable grid pagination.
+     *
+     * @return $this
+     */
+    public function disablePagination(bool $disable = true)
+    {
+        $this->model->usePaginate(!$disable);
+
+        return $this->option('show_pagination', !$disable);
+    }
+
+    /**
+     * Show grid pagination.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showPagination(bool $val = true)
+    {
+        return $this->disablePagination(!$val);
+    }
+
+}

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

@@ -15,7 +15,7 @@ use Illuminate\Support\Str;
  *
  * @method  Model model()
  */
-trait QuickSearch
+trait HasQuickSearch
 {
     /**
      * @var string

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

@@ -0,0 +1,190 @@
+<?php
+
+namespace Dcat\Admin\Grid\Concerns;
+
+use Closure;
+use Dcat\Admin\Grid\Tools;
+
+trait HasTools
+{
+    /**
+     * Header tools.
+     *
+     * @var Tools
+     */
+    protected $tools;
+
+    /**
+     * Setup grid tools.
+     */
+    public function setupTools()
+    {
+        $this->tools = new Tools($this);
+    }
+
+    /**
+     * @return Tools
+     */
+    public function getTools()
+    {
+        return $this->tools;
+    }
+
+    /**
+     * Setup grid tools.
+     *
+     * @param Closure $callback
+     *
+     * @return $this
+     */
+    public function tools(Closure $callback)
+    {
+        call_user_func($callback, $this->tools);
+
+        return $this;
+    }
+
+    /**
+     * Set grid batch-action callback.
+     *
+     * @param Closure $closure
+     *
+     * @return $this
+     */
+    public function batchActions(Closure $closure)
+    {
+        $this->tools(function (Tools $tools) use ($closure) {
+            $tools->batch($closure);
+        });
+
+        return $this;
+    }
+
+    /**
+     * Render custom tools.
+     *
+     * @return string
+     */
+    public function renderTools()
+    {
+        return $this->tools->render();
+    }
+
+    /**
+     * @param bool $val
+     * @return mixed
+     */
+    public function disableToolbar(bool $val = true)
+    {
+        return $this->option('show_toolbar', !$val);
+    }
+
+    /**
+     * @param bool $val
+     * @return mixed
+     */
+    public function showToolbar(bool $val = true)
+    {
+        return $this->disableToolbar(!$val);
+    }
+
+    /**
+     * Disable batch actions.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableBatchActions(bool $disable = true)
+    {
+        $this->tools->disableBatchActions($disable);
+
+        return $this;
+    }
+
+    /**
+     * Show batch actions.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showBatchActions(bool $val = true)
+    {
+        return $this->disableBatchActions(!$val);
+    }
+
+    /**
+     * Disable batch delete.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableBatchDelete(bool $disable = true)
+    {
+        $this->tools->batch(function ($action) use ($disable) {
+            $action->disableDelete($disable);
+        });
+
+        return $this;
+    }
+
+    /**
+     * Show batch delete.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showBatchDelete(bool $val = true)
+    {
+        return $this->disableBatchDelete(!$val);
+    }
+
+    /**
+     * Disable refresh button.
+     *
+     * @param bool $disable
+     * @return $this
+     */
+    public function disableRefreshButton(bool $disable = true)
+    {
+        $this->tools->disableRefreshButton($disable);
+
+        return $this;
+    }
+
+    /**
+     * Show refresh button.
+     *
+     * @param bool $val
+     * @return $this
+     */
+    public function showRefreshButton(bool $val = true)
+    {
+        return $this->disableRefreshButton(!$val);
+    }
+
+
+    /**
+     * If grid show toolbar.
+     *
+     * @return bool
+     */
+    public function allowToolbar()
+    {
+        if (
+            $this->option('show_toolbar')
+            && (
+                $this->getTools()->has() ||
+                $this->allowExportBtn() ||
+                $this->allowCreateBtn() ||
+                $this->allowQuickCreateBtn() ||
+                $this->allowResponsive() ||
+                !empty($this->variables['title'])
+            )
+        ) {
+            return true;
+        }
+
+        return false;
+    }
+
+}

+ 0 - 403
src/Grid/Concerns/Options.php

@@ -1,403 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Grid\Concerns;
-
-trait Options
-{
-    /**
-     * Options for grid.
-     *
-     * @var array
-     */
-    protected $options = [
-        'show_pagination'        => true,
-        'show_filter'            => true,
-        'show_actions'           => true,
-        'show_quick_edit_button' => true,
-        'show_edit_button'       => true,
-        'show_view_button'       => true,
-        'show_delete_button'     => true,
-        'show_row_selector'      => true,
-        'show_create_btn'        => true,
-        'show_quick_create_btn'  => true,
-        'show_bordered'          => false,
-        'show_toolbar'           => true,
-
-        'row_selector_style'      => 'primary',
-        'row_selector_circle'     => true,
-        'row_selector_clicktr'    => false,
-        'row_selector_label_name' => null,
-        'row_selector_bg'         => 'var(--20)',
-
-        'show_exporter'   => false,
-        'show_export_all' => true,
-        'show_export_current_page' => true,
-        'show_export_selected_rows' => true,
-        'export_limit'    => 50000,
-
-        'dialog_form_area'   => ['700px', '670px'],
-        'table_header_style' => 'table-header-gray',
-
-    ];
-
-    /**
-     * Get or set option for grid.
-     *
-     * @param string $key
-     * @param mixed  $value
-     *
-     * @return $this|mixed
-     */
-    public function option($key, $value = null)
-    {
-        if (is_null($value)) {
-            return $this->options[$key];
-        }
-
-        $this->options[$key] = $value;
-
-        return $this;
-    }
-
-    /**
-     * Disable grid pagination.
-     *
-     * @return $this
-     */
-    public function disablePagination(bool $disable = true)
-    {
-        $this->model->usePaginate(!$disable);
-
-        return $this->option('show_pagination', !$disable);
-    }
-
-    /**
-     * Show grid pagination.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showPagination(bool $val = true)
-    {
-        return $this->disablePagination(!$val);
-    }
-
-    /**
-     * Disable all actions.
-     *
-     * @return $this
-     */
-    public function disableActions(bool $disable = true)
-    {
-        return $this->option('show_actions', !$disable);
-    }
-
-    /**
-     * Show all actions.
-     *
-     * @return $this
-     */
-    public function showActions(bool $val = true)
-    {
-        return $this->disableActions(!$val);
-    }
-
-    /**
-     * Disable row selector.
-     *
-     * @return $this
-     */
-    public function disableRowSelector(bool $disable = true)
-    {
-        $this->tools->disableBatchActions($disable);
-
-        return $this->option('show_row_selector', !$disable);
-    }
-
-    /**
-     * Show row selector.
-     *
-     * @return $this
-     */
-    public function showRowSelector(bool $val = true)
-    {
-        return $this->disableRowSelector(!$val);
-    }
-
-    /**
-     * Disable grid filter.
-     *
-     * @return $this
-     */
-    public function disableFilter(bool $disable = true)
-    {
-//        $this->tools->disableFilterButton($disable);
-        $this->filter->disableCollapse($disable);
-
-        return $this->option('show_filter', !$disable);
-    }
-
-    /**
-     * Show grid filter.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showFilter(bool $val = true)
-    {
-        return $this->disableFilter(!$val);
-    }
-
-    /**
-     * Disable refresh button.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableRefreshButton(bool $disable = true)
-    {
-        $this->tools->disableRefreshButton($disable);
-
-        return $this;
-    }
-
-    /**
-     * Show refresh button.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showRefreshButton(bool $val = true)
-    {
-        return $this->disableRefreshButton(!$val);
-    }
-
-    /**
-     * Disable filter button.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableFilterButton(bool $disable = true)
-    {
-        $this->tools->disableFilterButton($disable);
-
-        return $this;
-    }
-
-    /**
-     * Show filter button.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showFilterButton(bool $val = true)
-    {
-        return $this->disableFilterButton(!$val);
-    }
-
-    /**
-     * Disable batch actions.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableBatchActions(bool $disable = true)
-    {
-        $this->tools->disableBatchActions($disable);
-
-        return $this;
-    }
-
-    /**
-     * Show batch actions.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showBatchActions(bool $val = true)
-    {
-        return $this->disableBatchActions(!$val);
-    }
-
-    /**
-     * Disable batch delete.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableBatchDelete(bool $disable = true)
-    {
-        $this->tools->batch(function ($action) use ($disable) {
-            $action->disableDelete($disable);
-        });
-
-        return $this;
-    }
-
-    /**
-     * Show batch delete.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showBatchDelete(bool $val = true)
-    {
-        return $this->disableBatchDelete(!$val);
-    }
-
-    /**
-     * Disable edit.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableEditButton(bool $disable = true)
-    {
-        $this->options['show_edit_button'] = !$disable;
-
-        return $this;
-    }
-
-    /**
-     * Show edit.
-     *
-     * @param bool $val
-     * @return $this
-     */
-    public function showEditButton(bool $val = true)
-    {
-        return $this->disableEditButton(!$val);
-    }
-
-    /**
-     * Disable quick edit.
-     *
-     * @return $this.
-     */
-    public function disableQuickEditButton(bool $disable = true)
-    {
-        $this->options['show_quick_edit_button'] = !$disable;
-
-        return $this;
-    }
-
-    /**
-     * Show quick edit button.
-     *
-     * @return $this.
-     */
-    public function showQuickEditButton(bool $val = true)
-    {
-        return $this->disableQuickEditButton(!$val);
-    }
-
-    /**
-     * Disable view action.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableViewButton(bool $disable = true)
-    {
-        $this->options['show_view_button'] = !$disable;
-
-        return $this;
-    }
-
-    /**
-     * Show view action.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function showViewButton(bool $val = true)
-    {
-        return $this->disableViewButton(!$val);
-    }
-
-    /**
-     * Disable delete.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function disableDeleteButton(bool $disable = true)
-    {
-        $this->options['show_delete_button'] = !$disable;
-
-        return $this;
-    }
-
-    /**
-     * Show delete button.
-     *
-     * @param bool $disable
-     * @return $this
-     */
-    public function showDeleteButton(bool $val = true)
-    {
-        return $this->disableDeleteButton(!$val);
-    }
-
-    /**
-     * Disable export.
-     *
-     * @return $this
-     */
-    public function disableExporter(bool $disable = true)
-    {
-        return $this->option('show_exporter', !$disable);
-    }
-
-    /**
-     * Show export button.
-     *
-     * @return $this
-     */
-    public function showExporter(bool $val = true)
-    {
-        return $this->disableExporter(!$val);
-    }
-
-    /**
-     * Remove create button on grid.
-     *
-     * @return $this
-     */
-    public function disableCreateButton(bool $disable = true)
-    {
-        return $this->option('show_create_btn', !$disable);
-    }
-
-    /**
-     * Show create button.
-     *
-     * @return $this
-     */
-    public function showCreateButton(bool $val = true)
-    {
-        return $this->disableCreateButton(!$val);
-    }
-
-    public function disableQuickCreateButton(bool $disable = true)
-    {
-        return $this->option('show_quick_create_btn', !$disable);
-    }
-
-    public function showQuickCreateButton(bool $val = true)
-    {
-        return $this->disableQuickCreateButton(!$val);
-    }
-
-    public function disableToolbar(bool $val = true)
-    {
-        return $this->option('show_toolbar', !$val);
-    }
-
-    public function showToolbar(bool $val = true)
-    {
-        return $this->disableToolbar(!$val);
-    }
-
-}

+ 2 - 2
src/Grid/Filter.php

@@ -27,7 +27,7 @@ use Dcat\Admin\Grid\Filter\Scope;
 use Dcat\Admin\Grid\Filter\StartWith;
 use Dcat\Admin\Grid\Filter\Where;
 use Dcat\Admin\Grid\Filter\Year;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Arr;
@@ -62,7 +62,7 @@ use Illuminate\Support\Facades\Input;
  */
 class Filter implements Renderable
 {
-    use BuilderEvents;
+    use HasBuilderEvents;
 
     /**
      * Ignore value.

+ 2 - 2
src/Layout/Content.php

@@ -4,13 +4,13 @@ namespace Dcat\Admin\Layout;
 
 use Closure;
 use Dcat\Admin\Admin;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Arr;
 
 class Content implements Renderable
 {
-    use BuilderEvents;
+    use HasBuilderEvents;
 
     /**
      * @var string

+ 2 - 2
src/Layout/Navbar.php

@@ -2,13 +2,13 @@
 
 namespace Dcat\Admin\Layout;
 
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Htmlable;
 use Illuminate\Contracts\Support\Renderable;
 
 class Navbar implements Renderable
 {
-    use BuilderEvents;
+    use HasBuilderEvents;
 
     /**
      * @var array

+ 2 - 2
src/MiniGrid.php

@@ -17,12 +17,12 @@ class MiniGrid extends Grid
         $this->disableExporter();
         $this->disableQuickCreateButton();
 
-        $this->options['row_selector_clicktr'] = true;
+        $this->option('row_selector_clicktr', true);
 
         $this->tools->disableBatchActions();
 
         $this->wrap(function ($view) {
-            return "<div class='card'>$view</div>";
+            return "<div class='box'>$view</div>";
         });
     }
 

+ 2 - 2
src/Show.php

@@ -8,7 +8,7 @@ use Dcat\Admin\Show\Field;
 use Dcat\Admin\Show\Newline;
 use Dcat\Admin\Show\Panel;
 use Dcat\Admin\Show\Relation;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Arr;
@@ -19,7 +19,7 @@ use Illuminate\Support\Traits\Macroable;
 
 class Show implements Renderable
 {
-    use BuilderEvents,
+    use HasBuilderEvents,
         Macroable {
             __call as macroCall;
         }

+ 4 - 4
src/Show/Field.php

@@ -3,8 +3,8 @@
 namespace Dcat\Admin\Show;
 
 use Dcat\Admin\Show;
-use Dcat\Admin\Traits\BuilderEvents;
-use Dcat\Admin\Traits\Definitions;
+use Dcat\Admin\Traits\HasBuilderEvents;
+use Dcat\Admin\Traits\HasDefinitions;
 use Dcat\Admin\Widgets\Dump;
 use Illuminate\Contracts\Support\Arrayable;
 use Illuminate\Contracts\Support\Renderable;
@@ -18,8 +18,8 @@ use Illuminate\Support\Traits\Macroable;
 
 class Field implements Renderable
 {
-    use BuilderEvents,
-        Definitions,
+    use HasBuilderEvents,
+        HasDefinitions,
         Macroable {
             __call as macroCall;
         }

+ 1 - 1
src/Traits/BuilderEvents.php → src/Traits/HasBuilderEvents.php

@@ -2,7 +2,7 @@
 
 namespace Dcat\Admin\Traits;
 
-trait BuilderEvents
+trait HasBuilderEvents
 {
     /**
      * Register a resolving listener.

+ 1 - 1
src/Traits/Definitions.php → src/Traits/HasDefinitions.php

@@ -2,7 +2,7 @@
 
 namespace Dcat\Admin\Traits;
 
-trait Definitions
+trait HasDefinitions
 {
     /**
      * Defined columns.

+ 2 - 2
src/Tree.php

@@ -3,7 +3,7 @@
 namespace Dcat\Admin;
 
 use Closure;
-use Dcat\Admin\Traits\BuilderEvents;
+use Dcat\Admin\Traits\HasBuilderEvents;
 use Dcat\Admin\Tree\Tools;
 use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Database\Eloquent\Model;
@@ -11,7 +11,7 @@ use Illuminate\Support\Traits\Macroable;
 
 class Tree implements Renderable
 {
-    use BuilderEvents,
+    use HasBuilderEvents,
         Macroable;
 
     /**