/** * Creates a new Diplomas model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Diplomas(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionUpdateDiploma() { $imagesModel = new Image(); if ($imagesModel->image_file = UploadedFile::getInstance($imagesModel, 'image_file')) { $psychologistId = Yii::$app->user->id; if (Diplomas::findOne(['psychologist_id' => $psychologistId]) === null) { $diploma = new Diplomas(); $diploma->psychologist_id = $psychologistId; $diploma->is_approved = 0; $diploma->save(); } if ($imagesModel->saveDiploma($psychologistId)) { return $this->redirect('index'); } else { throw new NotFoundHttpException('The requested page does not exist.'); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }