public function actionToggle($id, $attribute)
 {
     $model = $this->findModel($id);
     $studentId = $model->student_id;
     $student = Student::findOne($studentId);
     if (Yii::$app->user->can('updateStudent', ['student' => $student])) {
         $action = new ToggleAction('toggle', $this, ['modelClass' => Affiliation::className()]);
         return $action->run($id, $attribute);
     }
 }
 /**
  * Toggles a binary field from the summary grid
  * @param type $id
  * @param type $attribute
  * @return mixed ajax response
  * @throws ForbiddenHttpException
  */
 public function actionToggle($id, $attribute)
 {
     $accessParams = ['student' => Student::findOne($id)];
     if (Yii::$app->user->can('updateStudent', $accessParams)) {
         $action = new ToggleAction('toggle', $this, ['modelClass' => Student::className()]);
         return $action->run($id, $attribute);
     } else {
         throw new ForbiddenHttpException(Yii::t('app', 'You are not authorized to perform this action.'));
     }
 }
예제 #3
0
 public function actions()
 {
     return ['toggle' => ['class' => ToggleAction::className(), 'modelClass' => User::className(), 'onValue' => User::STATUS_ACTIVE, 'offValue' => User::STATUS_NOT_ACTIVE], 'suggestion' => ['class' => Suggestions::className()]];
 }