예제 #1
0
 /**
  * Finds the Vacancy model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Vacancy the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Vacancy::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 /**
  * Creates a new Review model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($vacancyId)
 {
     $model = new Review();
     $vacancy = Vacancy::findOne($vacancyId);
     if ($vacancy === null) {
         throw new HttpException(404, "This vacancy the Students Assistent is working for is not found");
     }
     $model->vacancy_id = $vacancyId;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }