/** * Creates a new EducationLevel model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Course(); $fact_id = Yii::$app->getRequest()->getQueryParam('id'); //ambil id dkat parameter /* print_r($fact_id); die();*/ $data['university'] = ""; $data['hasRecord'] = ""; if (empty($fact_id)) { $data['university'] = University::find()->indexBy('uni_id')->asArray()->all(); $data['hasRecord'] = 0; } else { $data['university'] = Institution::getUniFaculty($fact_id); $data['hasRecord'] = 1; } return $this->render('create', $data); /*if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->course_id]); } else { return $this->render('create', [ 'model' => $model, ]); }*/ }
/** * Creates a new Institution model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Institution(); $uni_id = Yii::$app->getRequest()->getQueryParam('id'); //ambil id dkat parameter $data['university'] = ""; $data['hasRecord'] = ""; if (empty($uni_id)) { $data['university'] = University::find()->indexBy('uni_id')->asArray()->all(); $data['hasRecord'] = 0; } else { //print_r($uni_id);$user = User::find()->->one(); $data['university'] = University::find()->where(array('uni_id' => $uni_id))->asArray()->all(); $data['hasRecord'] = 1; } $data['model'] = $model; return $this->render('create', $data); /*print_r($university); die();*/ /* if ($model->load(Yii::$app->request->post())) { return $this->render('create', [ 'model' => $model, 'university' => $data, ]); } else { return $this->render('create', [ 'model' => $model, ]); }*/ }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = University::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['uni_id' => $this->uni_id, 'uni_status' => $this->uni_status]); $query->andFilterWhere(['like', 'uni_code', $this->uni_code])->andFilterWhere(['like', 'uni_name', $this->uni_name]); return $dataProvider; }
/** * Finds the EducationLevel model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EducationLevel the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = University::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getUniversity() { return $this->hasOne(University::className(), ['uni_id' => 'uni_id']); }