Exemple #1
0
 public function updateRole($id, $data)
 {
     foreach ($data['module'] as $key => $value) {
         foreach ($value['role'] as $key2 => $value2) {
             $roleModule = new RoleModule();
             $roleModule->role = $id;
             $roleModule->module = $value['name'];
             $roleModule->hak_akses = $value2;
             $roleModule->save();
         }
     }
     return true;
 }
 public function actionDeleteRole()
 {
     if ($this->isDeleteAllowed()) {
         if (Yii::$app->request->get()) {
             RoleModule::deleteAll('role = ' . Yii::$app->request->get()['id']);
             Role::deleteAll('id = ' . Yii::$app->request->get()['id']);
             /*return $this->render('role_list');*/
             return $this->redirect(['security/role-management']);
         }
         return $this->render('role_list');
     } else {
         echo "You don't have access here";
         die;
     }
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRoleModules()
 {
     return $this->hasMany(RoleModule::className(), ['module' => 'id']);
 }