| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 | 
							- <?php
 
- namespace app\common\model;
 
- use think\Model;
 
- use think\facade\Db;
 
- class SysMenu extends Model
 
- {
 
-     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\common\model\SysMenu::where('url', $route)->find();
 
-         $active_pid = 0;
 
-         $breadCrumb = [];
 
-         if ($active) {
 
-             $active_pid = $active->pid;
 
-             $result = \app\common\model\SysMenu::find($active_pid);
 
-             // 如果还有上级
 
-             if ($result) {
 
-                 $res = \app\common\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
 
-         ];
 
-     }
 
- }
 
 
  |