123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\user\model;
- use think\Model;
- use think\Db;
- use think\Validate;
- use think\Request;
- /**
- * 角色-权限管理
- * @author Superbee
- *
- */
- class RoleRule extends Model{
-
- /**
- * 添加和更新的方法
- */
- public function addAndSave(){
- $data = request()->post();
- $aid = $data['id'];
- $this->db()->where(['aid'=>$data['id']])->delete();
-
- foreach ($data['rid'] as $v){
- $data = ['id'=>'', 'aid'=>$aid, 'rid'=>$v];
- $this->isUpdate(false)->save($data);
- }
- }
-
- /**
- * 根据id找到规则
- * @param unknown $aid
- */
- public function getRidByAid($aid){
- $array = [];
- $res = $this->db()->where(['aid'=>$aid])->select();
-
- foreach ($res as $v){
- $array[] = $v['rid'];
- }
-
- return $array;
- }
-
- }
|