SystemMenuDao.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\extra\dao\system;
  3. use app\extra\basic\Dao;
  4. use app\model\system\SystemMenu;
  5. class SystemMenuDao extends Dao
  6. {
  7. /**
  8. * 设置模型
  9. * @return string
  10. */
  11. protected function setModel(): string
  12. {
  13. return SystemMenu::class;
  14. }
  15. // public function getList(array $where,string $field = '*',int $page = 0, int $limit = 0,string $order='id desc')
  16. // {
  17. // return $this->getModel()->where($where)->field($field)->when($page&&$limit,function($query)use($page,$limit){
  18. // $query->page($page,$limit);
  19. // })->select();
  20. // }
  21. /**
  22. * 获取权限菜单列表
  23. * @param array $where
  24. * @param array|null $field
  25. * @return array|\crmeb\basic\BaseModel[]|\think\Collection
  26. * @throws \ReflectionException
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\DbException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. */
  31. public function getMenusRoule(array $where, ?array $field = [])
  32. {
  33. if (!$field) {
  34. $field = ['id', 'title', 'icon', 'pid', 'sort', 'path', 'status'];
  35. }
  36. return $this->getModel()->where($where)->field($field)->order('sort DESC,id DESC')->failException(false)->select();
  37. }
  38. }