fefo-p / admin-panel
Spatie/Laravel-Permission的后台管理面板
Requires
- php: ^8.1
- illuminate/container: ^9.52.16
- illuminate/support: ^9.52.16
- laravel/jetstream: ^2.16.2
- livewire/livewire: ^2.12.6
- rappasoft/laravel-livewire-tables: ^2.15.0
- spatie/laravel-permission: ^5.11.1
- wire-elements/modal: ^1.0.8
Requires (Dev)
- barryvdh/laravel-debugbar: ^3.13.4
README
关于Admin Panel
Admin Panel是一个基于TALL的解决方案,可以管理用户、角色和权限。它需要几个composer包。
这些都是必需的依赖项,如果需要,将安装它们。
安装
-仅限开发-
要开始,请将本地仓库添加到Composer
{ "repositories": { "admin-panel": { "type": "path", "url": "/path-to-downloaded-file/fefo-p/admin-panel", "options": { "symlink": true } } } }
-生产-
然后,通过Composer要求此包
composer require fefo-p/admin-panel
警告
在运行安装命令之前,您可能希望发布配置和迁移,因为将自动迁移数据库。
要找出可发布的选项,请执行以下命令
php artisan vendor:publish并检查带有adminpanel的每个条目
如果有疑问,请检查laravel的artisan CLI文档
认真地说,您已经被警告了...
初始设置
执行以下命令进行初始设置。
php artisan adminpanel:install
它将创建一个名为administrador
的角色,具有三个权限
- 创建、查看、编辑和删除用户
- 创建、查看、编辑和删除角色
- 创建、查看、编辑和删除权限
安装命令中有一些可选参数,但不是必需的
--profile-image
更新jetstream以使用个人资料图片,并发布默认的匿名个人资料图片
--verification
使User模型实现MustVerifyEmail,并在fortify中允许电子邮件验证功能
--with-user
创建默认管理员用户
注意
待办事项: 在安装时请求用户详细信息
php artisan adminpanel:install [--with-user] [--profile-image] [--verification]
环境设置
如果有外部和内部用户的组合(那么您只需要管理内部用户的权限),则应添加两个环境变量
ADMINPANEL_EXTERNAL_USERS=true ADMINPANEL_EXTERNAL_COLUMN='externo'
第一个变量表示是否存在外部用户,第二个变量表示在用户表中负责告诉我们用户是外部还是内部的用户列。
资产
您可以通过执行命令发布所有资产,或者仅选择要发布的单个资产
php artisan vendor:publish --tag=adminpanel
配置
您可以通过adminpanel.php
配置文件自定义模态框。这包括一些附加选项,如...
要发布配置,请运行vendor:publish命令
php artisan vendor:publish --tag=adminpanel-config
<?php return [ /* |-------------------------------------------------------------------------- | Include CSS |-------------------------------------------------------------------------- | | The modal uses TailwindCSS, if you don't use TailwindCSS you will need | to set this parameter to true. This includes the modern-normalize css. | */ 'include_css' => false, /* |-------------------------------------------------------------------------- | Include JS |-------------------------------------------------------------------------- | | Livewire UI will inject the required Javascript in your blade template. | If you want to bundle the required Javascript you can set this to false | and add `require('vendor/wire-elements/modal/resources/js/modal');` | to your script bundler like webpack. | */ 'include_js' => true, /* |-------------------------------------------------------------------------- | Modal Component Defaults |-------------------------------------------------------------------------- | | Configure the default properties for a modal component. | | Supported modal_max_width | 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', '7xl' */ 'component_defaults' => [ 'modal_max_width' => '2xl', 'close_modal_on_click_away' => true, 'close_modal_on_escape' => true, 'close_modal_on_escape_is_forceful' => true, 'dispatch_close_event' => false, 'destroy_on_close' => false, ], ];
使用SSL设置Vite
import { defineConfig } from 'vite'; import laravel, { refreshPaths } from 'laravel-vite-plugin'; // add these 2 lines const domain = "broadcast.test"; const homedir = require("os").homedir(); // end add export default defineConfig({ plugins: [ laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js', ], refresh: [ ...refreshPaths, 'app/Http/Livewire/**', ], }), ], // add this block server: { https: { key: homedir + "/.config/valet/Certificates/" + domain + ".key", cert: homedir + "/.config/valet/Certificates/" + domain + ".crt", }, host: domain, hmr: { host: domain, }, }, // end add });
Laravel Websockets
confif/broadcasting.php
[...] 'connections' => [ 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ // 'host' => env('PUSHER_HOST', 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'host' => '-----------------your-servers-url-----------------', // 'port' => env('PUSHER_PORT', 443), 'port' => env('PUSHER_PORT', 6001), 'scheme' => env('PUSHER_SCHEME', 'https'), 'encrypted' => true, 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', ], 'client_options' => [ // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html ], ], [...]
使用SSL的Websockets
.env
PUSHER_APP_ID=something_id PUSHER_APP_KEY=something_key PUSHER_APP_SECRET=something_secret PUSHER_HOST=-----------------------domain.com----------------------- PUSHER_PORT=6001 PUSHER_SCHEME=https LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT='/some-path-to-ssl-certificates/bcast.test.crt' LARAVEL_WEBSOCKETS_SSL_LOCAL_PK='/some-path-to-ssl-certificates/bcast.test.key'
连接到Echo
resources/views/layouts/app.blade.php
document.onreadystatechange = function () { if (document.readyState === 'complete') { Echo.join('logged_in') .here((users) => { console.log(users); }) .joining((user) => { console.log(user.name); }) .leaving((user) => { console.log(user.name); }) .listen('OrderStatusUpdated', (e) => { console.log(e); }) .error((error) => { console.error(error); }); } };
致谢
许可证
Admin Panel是开源软件,许可协议为MIT许可证。