# 原理通过循环,把每个方法拿出来,在公共里面进行判断 ~~~ $role_id = explode(',',$info['role_id']); static $roles; foreach( $role_id as $v){ $roles[] = \app\admin\model\Role::where('id',$v)->find(); } static $privileges ; foreach($roles as $k=>$c){ $privileges[]= $c['privilege_id']; } static $privile ; foreach($privileges as $d){ $privile[] = \app\admin\model\Privileges::Wherein('id',$d)->select(); } static $privilees; foreach($privile as $e){ foreach($e as $ee){ $privilees[] =$ee['m_name'].'/'.$ee['c_name'].'/'.$ee['a_name']; } } // \think\facade\Session::set('priviles',$privilees); ~~~ # :-: 公共控制器 ~~~ $rule = request ()->module () . '/' . request()->controller () . '/' . request()->action (); // halt($rule); // halt(\session('priviles')); if ( !in_array($rule,\session('priviles'))){ return $this->redirect('/admin/index'); } ~~~