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; } }
/** * @return \yii\db\ActiveQuery */ public function getRoleModules() { return $this->hasMany(RoleModule::className(), ['module' => 'id']); }