orderBy('sort','desc'); if(is_array($where)&&count($where)>0){ $data=$data->where($where); } $data=$data->paginate($limit); return $data->toArray(); } protected function addGroup($data){ if(($res=$this->checkCode($data['group_code'],$data['group_name'])) < 0 ){ return $res; } if(!isset($data['create_at'])){ $data['create_at']=date('Y-m-d H:i:s'); } if(!isset($data['identity'])){ $data['identity']=UUID(); } $resd=$this->insert($data); if(!$resd){ return -240002; } return 1; } //检测重复 protected function checkCode($code,$name){ $res=$this->where('group_code',$code)->orWhere('group_name',$name)->first(); if($res){ return -240001; } return 1; } protected function getGroups($ids){ $data=$this->whereIn('id',$ids)->get(); if(!$data){ return -240004; } return $data->toArray(); } protected function getInfoById($id){ $data=$this->where('group_code',$id)->first(); if(!$data){ return -240001; } return $data->toArray(); } protected function getAllInfo(){ $data=$this->orderBy('group_code','asc')->get(); if(!$data){ return array(); } return $data->toArray(); } }