| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\extra\service\system;
- use app\extra\basic\Service;
- use app\extra\dao\system\SystemMenuDao;
- use app\model\inmei\InmeiMenu;
- use app\model\system\SystemMenu;
- class MenuService extends Service
- {
- /**
- * 设置模型
- * @return string
- */
- public function __construct()
- {
- $this->dao = new SystemMenuDao();
- }
- /**
- * @param int $super
- * @param int $hide
- * @param int $type
- * @return array
- */
- public function getMenuList(int $roles = 0,int $hide = 0,int $type = 1): array
- {
- $model = new SystemMenu();
- try {
- if($roles>-1){
- $systemRoleService = new SystemRoleService();
- $rules = $systemRoleService->getColumn(['id'=>$roles],'rules');
- $rulesStr = array_unique(explode(',', implode(',', $rules)));
- $data = $model->where("status",1)->whereIn('id',$rulesStr)->where("from",$type)->order("sort","asc")->select();
- }else{
- $data = $model->where("status",1)->where("from",$type)->order("sort","asc")->select();
- }
- } catch (\Throwable $throwable) {
- return [];
- }
- return $data->isEmpty()?[]:$data->toArray();
- }
- }
|