public function actionIndex()
 {
     $methods = Role::$methods;
     $fields = Role::accessFilter();
     $controllers = Role::$controllers;
     $roleId = isset($_GET['roleId']) == null ? 1 : $_GET['roleId'];
     $model = $this->findModel($roleId);
     $model->role_name = $roleId;
     $sql = '';
     //echo '<pre>';print_r($_POST['Roles']); exit(0);
     if ($model->load(Yii::$app->request->post())) {
         \app\models\Access::deleteAll('roleId = :roleId', [':roleId' => $roleId]);
         foreach ($_POST['Roles'] as $keys => $values) {
             foreach ($values as $k => $v) {
                 //if($v=='on')
                 $sql .= ' INSERT INTO access (roleId,controller,method) values ("' . $roleId . '","' . $keys . '","' . $k . '"); ';
             }
         }
         if ($sql) {
             Yii::$app->db->createCommand($sql)->execute();
             Yii::$app->session->setFlash('success', 'Successfully, Update access role!');
         }
     }
     return $this->render('index', ['model' => $model, 'methods' => $methods, 'fields' => $fields, 'controllers' => $controllers, 'roleId' => $roleId]);
 }
 public static function fieldsArray()
 {
     $fields = \app\models\Role::accessFilter();
     $return = [];
     foreach ($fields as $keys => $values) {
         foreach ($values as $k => $v) {
             $return[] = strtolower($keys) . '.' . $v;
         }
     }
     return $return;
 }