MenuLists.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\adminapi\lists\decorate;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\enum\MenuEnum;
  17. use app\common\model\decorate\Menu;
  18. /**
  19. * 菜单列表
  20. * Class MenuLists
  21. * @package app\adminapi\lists\decorate
  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 ljj
  32. * @date 2022/2/14 11:29 上午
  33. */
  34. public function lists(): array
  35. {
  36. $lists = (new Menu())->field('id,name,image,link_type,link_address,sort,status')
  37. ->order(['sort'=>'asc','id'=>'desc'])
  38. ->append(['link_address_desc','status_desc'])
  39. ->limit($this->limitOffset, $this->limitLength)
  40. ->select()
  41. ->toArray();
  42. foreach ($lists as &$list) {
  43. $list['link_address_desc'] = MenuEnum::getLinkDesc($list['link_type']).':'.$list['link_address_desc'];
  44. }
  45. return $lists;
  46. }
  47. /**
  48. * @notes 菜单总数
  49. * @return int
  50. * @author ljj
  51. * @date 2022/2/14 11:29 上午
  52. */
  53. public function count(): int
  54. {
  55. return (new Menu())->count();
  56. }
  57. }