sassId = $sassid; } /** * @param $post */ public function saveRole($post) { $save['name'] = $post['name']; $save['status'] = $post['status']; if($post['id']) { $info = $this->where("name",$post['name'])->find(); if(!empty($info) && $info['id'] != $post['id'] ) { return self::setErrorInfo('角色名重复了'); } $this->where('id',$post['id'])->save($save); return true; } else { $this->insert([ 'name' => $post['name'], 'status' => $post['status'] ]); } return true; } /** * 获取角色数据 * @param $id * @param string $field * @return mixed */ public function getRoleId($id,$field = '*') { $this->getRoleData(); foreach ($this->roleData as $v) { if($v['id'] == $id) { return $field == '*' ? $v : $v[$field]; } } } public function getRoleData(){ if(empty($this->roleData)) $this->roleData = $this->where('status',1)->select(); return $this->roleData; } }