Exemplo n.º 1
0
 public function actionChangeStatus()
 {
     $examId = \Yii::$app->request->post('examId');
     $status = \Yii::$app->request->post('status');
     $model = Exam::findOne(['id' => $examId]);
     $model->status = $status;
     if ($model->changeStatus()) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function updateExam($id)
 {
     $model = Exam::findOne(['id' => $id]);
     $model->attributes = $this->attributes;
     if ($model->validate()) {
         $model->save();
     } else {
         foreach ($model->errors as $key => $value) {
             $this->addError($key, $model->getFirstError($key));
         }
     }
     return $model;
 }