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' => Promotion::className()]);
         return $action->run($id, $attribute);
     }
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery relation
  */
 public function getPromotions()
 {
     return $this->hasMany(Promotion::className(), ['student_id' => 'id']);
 }