"int", "pid" => "int", "name" => "varchar", "url" => "varchar", "type" => "tinyint", "method" => "tinyint", "icon" => "varchar", "sort" => "smallint", "open" => "tinyint", "index_button" => "tinyint" ]; public static function getUserMenuList($rid) { if ($rid === 1) { // 超级管理员 $data = self::field('id, pid, name, url, type, icon')->select(); } else { $roleModel = new SysRole(); $permission_ids = $roleModel->getpermissionIds($rid); $data = self::where('id', 'IN', $permission_ids)->field('id, pid, name, url, icon')->select(); } return list_tree($data); } public static function queryButtonPermissionsByRoleid($rid) { if ($rid === 1) { // 超级管理员 $data = self::where('type', 2)->column('url'); } else { $roleModel = new SysRole(); $permission_ids = $roleModel->getpermissionIds($rid); $data = self::where('id', 'IN', $permission_ids)->where('type', 2)->column('url'); } return $data; } /** * 面包屑 */ public static function getBreadCrumb($route) { $active = \app\model\SysMenu::where('url', $route)->find(); $active_pid = 0; $breadCrumb = []; if ($active) { $active_pid = $active->pid; $result = \app\model\SysMenu::find($active_pid); // 如果还有上级 if ($result) { $res = \app\model\SysMenu::find($result->pid); // 如果还有上级 if ($res) { $active_pid = $result->pid; $breadCrumb[] = [ 'url' => $res['url'], 'title' => $res['name'], ]; } $breadCrumb[] = [ 'url' => $result['url'], 'title' => $result['name'], ]; } $breadCrumb[] = [ 'url' => $active['url'], 'title' => $active['name'], ]; } else { $breadCrumb[] = [ 'url' => null, 'title' => '我的桌面', ]; } return [ 'active_pid' => $active_pid, 'breadCrumb' => $breadCrumb ]; } /** * 后台首页快捷方式 */ public static function getIndexButton() { return self::where('index_button', 1)->where('type', 1)->select(); } public static function getMenuList() { return self::where('type', 1)->select(); } }