/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = LearningArea::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(['id' => $this->id, 'grade_level_id' => $this->grade_level_id, 'subject_id' => $this->subject_id, 'sequence' => $this->sequence, 'semester' => $this->semester, 'revision' => $this->revision]); return $dataProvider; }
public function actionLists($id) { $subjects = LearningArea::find()->where(['grade_level_id' => $id])->orderBy('sequence', SORT_ASC)->all(); $count = count($subjects); if ($subjects > 0) { for ($x = 0; $x < $count; $x++) { //$name = Subject::find()->where(['id' => $subject->id])->all(); echo "<option value='" . $subjects[$x]['subject_id'] . "'>" . $subjects[$x]->subject->subject_name . "</option>"; } } else { echo "<option></option>"; } }
/** * Finds the LearningArea model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @param integer $subject_id * @return LearningArea the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id, $subject_id) { if (($model = LearningArea::findOne(['id' => $id, 'subject_id' => $subject_id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getLearningAreas() { return $this->hasMany(LearningArea::className(), ['subject_id' => 'id']); }