/** * Lists all Relation models. * @return mixed */ public function actionIndex($role) { if (\Yii::$app->request->isPost) { $selectedPermissions = LuLu::getPostValue('Permission'); Relation::AddBatchItems($role, $selectedPermissions); return $this->redirect(['index', 'role' => $role]); } $allPermissions = Permission::getAllPermissionsGroupedByCategory(); $rolePermissions = Relation::find()->select(['permission', 'value'])->where(['role' => $role])->indexBy('permission')->all(); $categories = Permission::getCategoryItems(); $role = Role::findOne(['id' => $role]); return $this->render('index', ['rolePermissions' => $rolePermissions, 'allPermissions' => $allPermissions, 'categories' => $categories, 'role' => $role]); }
/** * Finds the Role model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Role the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Role::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }