MenuLists.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\tenantapi\lists\auth;
  15. use app\tenantapi\lists\BaseAdminDataLists;
  16. use app\common\model\auth\TenantSystemMenu;
  17. use think\db\exception\DbException;
  18. /**
  19. * 菜单列表
  20. * Class MenuLists
  21. * @package app\tenantapi\lists\auth
  22. */
  23. class MenuLists extends BaseAdminDataLists
  24. {
  25. /**
  26. * @notes 获取菜单列表
  27. * @return array
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @author 段誉
  32. * @date 2022/6/29 16:41
  33. */
  34. public function lists(): array
  35. {
  36. $lists = TenantSystemMenu::order(['sort' => 'desc', 'id' => 'asc'])
  37. ->select()
  38. ->toArray();
  39. return linear_to_tree($lists, 'children');
  40. }
  41. /**
  42. * @notes 获取菜单数量
  43. * @return int
  44. * @throws DbException
  45. * @author 段誉
  46. * @date 2022/6/29 16:41
  47. */
  48. public function count(): int
  49. {
  50. return TenantSystemMenu::count();
  51. }
  52. }