Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Section::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'level_id' => $this->level_id]);
     $query->andFilterWhere(['like', 'section_name', $this->section_name]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionLists($id)
 {
     $countSection = Section::find()->where(['level_id' => $id])->count();
     $Section = Section::find()->where(['level_id' => $id])->all();
     if ($countSection > 0) {
         foreach ($Section as $section) {
             echo "<option value'" . $section->id . "'>" . $section->section_name . "</option>";
         }
     } else {
         echo "<option></option>";
     }
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSections()
 {
     return $this->hasMany(Section::className(), ['level_id' => 'id']);
 }