diff --git a/app/AdminGuide/Controllers/AuthController.php b/app/AdminGuide/Controllers/AuthController.php new file mode 100644 index 0000000..049a1f3 --- /dev/null +++ b/app/AdminGuide/Controllers/AuthController.php @@ -0,0 +1,9 @@ +header('仪表盘') + ->description('数据详情') + ->body(function (Row $row) { + $row->column(6, function (Column $column) { + $column->row(Dashboard::title()); + $column->row(new Examples\Tickets()); + }); + + $row->column(6, function (Column $column) { + $column->row(function (Row $row) { + $row->column(6, new Examples\NewUsers()); + $row->column(6, new Examples\NewDevices()); + }); + + $column->row(new Examples\Sessions()); + $column->row(new Examples\ProductOrders()); + }); + }); + } +} diff --git a/app/AdminGuide/Metrics/Examples/NewDevices.php b/app/AdminGuide/Metrics/Examples/NewDevices.php new file mode 100644 index 0000000..eb0b9c7 --- /dev/null +++ b/app/AdminGuide/Metrics/Examples/NewDevices.php @@ -0,0 +1,100 @@ +primary(), $color->alpha('blue2', 0.5)]; + + $this->title('New Devices'); + $this->subTitle('Last 30 days'); + $this->chartLabels($this->labels); + // 设置图表颜色 + $this->chartColors($colors); + } + + /** + * 渲染模板 + * + * @return string + */ + public function render() + { + $this->fill(); + + return parent::render(); + } + + /** + * 写入数据. + * + * @return void + */ + public function fill() + { + $this->withContent(44.9, 28.6); + + // 图表数据 + $this->withChart([44.9, 28.6]); + } + + /** + * 设置图表数据. + * + * @param array $data + * + * @return $this + */ + public function withChart(array $data) + { + return $this->chart([ + 'series' => $data + ]); + } + + /** + * 设置卡片头部内容. + * + * @param mixed $desktop + * @param mixed $mobile + * + * @return $this + */ + protected function withContent($desktop, $mobile) + { + $blue = Admin::color()->alpha('blue2', 0.5); + + $style = 'margin-bottom: 8px'; + $labelWidth = 120; + + return $this->content( + << +
New Tickets
+ {$new} +Open Tickets
+ {$open} +Response Time
+ {$response} +
',
+
+ /*
+ |--------------------------------------------------------------------------
+ | User default avatar
+ |--------------------------------------------------------------------------
+ |
+ | Set a default avatar for newly created users.
+ |
+ */
+ 'default_avatar' => '@admin/images/default-avatar.jpg',
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin route settings
+ |--------------------------------------------------------------------------
+ |
+ | The routing configuration of the admin page, including the path prefix,
+ | the controller namespace, and the default middleware. If you want to
+ | access through the root path, just set the prefix to empty string.
+ |
+ */
+ 'route' => [
+ 'domain' => env('ADMIN_ROUTE_DOMAIN'),
+
+ 'prefix' => 'admin-guide',
+
+ 'namespace' => 'App\\AdminGuide\\Controllers',
+
+ 'middleware' => ['web', 'admin'],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin install directory
+ |--------------------------------------------------------------------------
+ |
+ | The installation directory of the controller and routing configuration
+ | files of the administration page. The default is `app/Admin`, which must
+ | be set before running `artisan admin::install` to take effect.
+ |
+ */
+ 'directory' => app_path('AdminGuide'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin html title
+ |--------------------------------------------------------------------------
+ |
+ | Html title for all pages.
+ |
+ */
+ 'title' => '地接管理后台',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Assets hostname
+ |--------------------------------------------------------------------------
+ |
+ */
+ 'assets_server' => env('ADMIN_ASSETS_SERVER'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Access via `https`
+ |--------------------------------------------------------------------------
+ |
+ | If your page is going to be accessed via https, set it to `true`.
+ |
+ */
+ 'https' => env('ADMIN_HTTPS', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin auth setting
+ |--------------------------------------------------------------------------
+ |
+ | Authentication settings for all admin pages. Include an authentication
+ | guard and a user provider setting of authentication driver.
+ |
+ | You can specify a controller for `login` `logout` and other auth routes.
+ |
+ */
+ 'auth' => [
+ 'enable' => true,
+
+ 'controller' => App\AdminGuide\Controllers\AuthController::class,
+
+ 'guard' => 'admin-guide',
+
+ 'guards' => [
+ 'admin-guide' => [
+ 'driver' => 'session',
+ 'provider' => 'admin-guide',
+ ],
+ ],
+
+ 'providers' => [
+ 'admin-guide' => [
+ 'driver' => 'eloquent',
+ 'model' => Dcat\Admin\Models\Administrator::class,
+ ],
+ ],
+
+ // Add "remember me" to login form
+ 'remember' => true,
+
+ // All method to path like: auth/users/*/edit
+ // or specific method to path like: get:auth/users.
+ 'except' => [
+ 'auth/login',
+ 'auth/logout',
+ ],
+
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | The global Grid setting
+ |--------------------------------------------------------------------------
+ */
+ 'grid' => [
+
+ // The global Grid action display class.
+ 'grid_action_class' => Dcat\Admin\Grid\Displayers\DropdownActions::class,
+
+ // The global Grid batch action display class.
+ 'batch_action_class' => Dcat\Admin\Grid\Tools\BatchActions::class,
+
+ // The global Grid pagination display class.
+ 'paginator_class' => Dcat\Admin\Grid\Tools\Paginator::class,
+
+ 'actions' => [
+ 'view' => Dcat\Admin\Grid\Actions\Show::class,
+ 'edit' => Dcat\Admin\Grid\Actions\Edit::class,
+ 'quick_edit' => Dcat\Admin\Grid\Actions\QuickEdit::class,
+ 'delete' => Dcat\Admin\Grid\Actions\Delete::class,
+ 'batch_delete' => Dcat\Admin\Grid\Tools\BatchDelete::class,
+ ],
+
+ // The global Grid column selector setting.
+ 'column_selector' => [
+ 'store' => Dcat\Admin\Grid\ColumnSelector\SessionStore::class,
+ 'store_params' => [
+ 'driver' => 'file',
+ ],
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin helpers setting.
+ |--------------------------------------------------------------------------
+ */
+ 'helpers' => [
+ 'enable' => true,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin permission setting
+ |--------------------------------------------------------------------------
+ |
+ | Permission settings for all admin pages.
+ |
+ */
+ 'permission' => [
+ // Whether enable permission.
+ 'enable' => true,
+
+ // All method to path like: auth/users/*/edit
+ // or specific method to path like: get:auth/users.
+ 'except' => [
+ '/',
+ 'auth/login',
+ 'auth/logout',
+ 'auth/setting',
+ ],
+
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin menu setting
+ |--------------------------------------------------------------------------
+ |
+ */
+ 'menu' => [
+ 'cache' => [
+ // enable cache or not
+ 'enable' => false,
+ 'store' => 'file',
+ ],
+
+ // Whether enable menu bind to a permission.
+ 'bind_permission' => true,
+
+ // Whether enable role bind to menu.
+ 'role_bind_menu' => true,
+
+ // Whether enable permission bind to menu.
+ 'permission_bind_menu' => true,
+
+ 'default_icon' => 'feather icon-circle',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin upload setting
+ |--------------------------------------------------------------------------
+ |
+ | File system configuration for form upload files and images, including
+ | disk and upload path.
+ |
+ */
+ 'upload' => [
+
+ // Disk in `config/filesystem.php`.
+ 'disk' => 'public',
+
+ // Image and file upload path under the disk above.
+ 'directory' => [
+ 'image' => 'images',
+ 'file' => 'files',
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | dcat-admin database settings
+ |--------------------------------------------------------------------------
+ |
+ | Here are database settings for dcat-admin builtin model & tables.
+ |
+ */
+ 'database' => [
+
+ // Database connection for following tables.
+ 'connection' => '',
+
+ // User tables and model.
+ 'users_table' => 'guides',
+ 'users_model' => Dcat\Admin\Models\Administrator::class,
+
+ // Role table and model.
+ 'roles_table' => 'admin_guide_roles',
+ 'roles_model' => Dcat\Admin\Models\Role::class,
+
+ // Permission table and model.
+ 'permissions_table' => 'admin_guide_permissions',
+ 'permissions_model' => Dcat\Admin\Models\Permission::class,
+
+ // Menu table and model.
+ 'menu_table' => 'admin_guide_menu',
+ 'menu_model' => Dcat\Admin\Models\Menu::class,
+
+ // Pivot table for table above.
+ 'role_users_table' => 'admin_guide_role_users',
+ 'role_permissions_table' => 'admin_guide_role_permissions',
+ 'role_menu_table' => 'admin_guide_role_menu',
+ 'permission_menu_table' => 'admin_guide_permission_menu',
+ 'settings_table' => 'admin_guide_settings',
+ 'extensions_table' => 'admin_guide_extensions',
+ 'extension_histories_table' => 'admin_guide_extension_histories',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Application layout
+ |--------------------------------------------------------------------------
+ |
+ | This value is the layout of admin pages.
+ */
+ 'layout' => [
+ // default, blue, blue-light, green
+ 'color' => 'blue-light',
+
+ // sidebar-separate
+ 'body_class' => [],
+
+ 'horizontal_menu' => false,
+
+ 'sidebar_collapsed' => false,
+
+ // light, primary, dark
+ 'sidebar_style' => 'light',
+
+ 'dark_mode_switch' => false,
+
+ // bg-primary, bg-info, bg-warning, bg-success, bg-danger, bg-dark
+ 'navbar_color' => '',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | The exception handler class
+ |--------------------------------------------------------------------------
+ |
+ */
+ 'exception_handler' => Dcat\Admin\Http\Exception\Handler::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Enable default breadcrumb
+ |--------------------------------------------------------------------------
+ |
+ | Whether enable default breadcrumb for every page content.
+ */
+ 'enable_default_breadcrumb' => true,
+];
diff --git a/config/admin.php b/config/admin.php
index 16f1f98..a85a467 100644
--- a/config/admin.php
+++ b/config/admin.php
@@ -5,6 +5,7 @@ return [
// 设置为true启用,false则是停用
'admin-agent' => true,
'admin-supplier' => true,
+ 'admin-guide' => true,
],
/*