/** * 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.')); } }
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); } }