thinkphp6的插件扩展:链接: https://pan.baidu.com/s/1WZdFBv95PFDQXlLF9JkaXQ 提取码: kv8v
1.按步骤创建数据表,
用户表:
根据自己的情况而定
能和中间表(gruop_access)关联起来就行
权限表:
角色表:
用户所属角色表:
2.composer代码下来
,
composer代码下来后会在config文件多出一个auth.php, 在里面可以更改表的名字
3.composer下来后
<?php
namespace app\admin\controller;
use app\BaseController;
use think\facade\View;
use think\wenhainan\Auth;
class AdminBase extends BaseController
{
public function initialize()
{
$controller = strtolower(request()->controller());
$action = strtolower(request()->action());
$auth = Auth::instance();
// dump($auth);exit;
// 检测权限
if(!$auth->check($controller.'-'.$action,1)){// 第一个参数是规则名称,第二个参数是用户UID
//有显示操作按钮的权限
dump('您没有权限访问');
}
}
}