/**
  * @param Permission $permission
  * @return Permission
  */
 public static function create($permission)
 {
     // Create Permission
     $permission->save();
     // Return Permission
     return $permission;
 }
 public function actionCreate($type = null)
 {
     $model = new Permission();
     $model->type = $type;
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post(), 'Permission') && $model->validate()) {
         if (PermissionService::create($model)) {
             $binder = new Binder();
             $binder->binderId = $model->id;
             $binder->load(Yii::$app->request->post(), 'Binder');
             PermissionService::bindRoles($binder);
             $this->redirect($this->returnUrl);
         }
     }
     $roles = RoleService::getIdNameListByType($type);
     return $this->render('create', ['model' => $model, 'roles' => $roles]);
 }
Example #3
0
 /**
  * @return array - Permission
  */
 public function getPermissions()
 {
     return $this->hasMany(Permission::className(), ['id' => 'permissionId'])->viaTable(CoreTables::TABLE_ROLE_PERMISSION, ['roleId' => 'id']);
 }
Example #4
0
 /**
  * @return Permission - from the mapping.
  */
 public function getPermission()
 {
     return $this->hasOne(Permission::className(), ['id' => 'permissionId']);
 }