/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($job_id) { $model = new JobApplication(); $job_description_model = JobDescription::model()->findByPk($job_id); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['JobApplication'])) { $model->attributes = $_POST['JobApplication']; $model->resume_path = CUploadedFile::getInstance($model, 'resume_path'); $model->status = 1; $model->applied_on = new CDbExpression("NOW()"); if ($model->save()) { if (!is_null($model->resume_path)) { $model->resume_path->saveAs(Yii::app()->basePath . '/../user_uploads/' . $model->id . '.' . $model->resume_path->getExtensionName()); } $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'job_description_model' => $job_description_model, 'job_id' => $job_id)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return JobDescription the loaded model * @throws CHttpException */ public function loadModel($id) { $model = JobDescription::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function postAddJobDescription() { $jd = new JobDescription(); $jd->course_id = $_POST['course_id']; $jd->job_id = $_POST['job_id']; if ($jd->save()) { return 1; } else { return 0; } }