Exemplo n.º 1
0
 /**
  * getSection is a public function
  * here we fetch all the topics under
  * the sectionId reference
  * @param INT $sectionId
  * @return ARRAY $result
  */
 public function getSection($sectionId)
 {
     $query = Topic::find();
     $query->where('ParentId IS NULL');
     $query->andFilterWhere(['SectionId' => $sectionId]);
     $query->orderBy('order');
     $query->with('topics');
     $result = $query->all();
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTopics()
 {
     return $this->hasMany(Topic::className(), ['SectionId' => 'SectionId']);
 }
Exemplo n.º 3
0
 /**
  * To get a topic list of a specific section on ajax call.
  * 
  */
 public function actionAjaxtopictaglist()
 {
     $sectionId = Yii::$app->request->post("sectionId", "");
     echo Html::tag('option', Html::encode("Please select"), ['value' => '']);
     if ($sectionId) {
         $query = Topic::find();
         $query->andFilterWhere(['SectionId' => $sectionId]);
         $query->orderBy('Order');
         $topics = $query->all();
         if (!empty($topics)) {
             foreach ($topics as $topic) {
                 echo Html::tag('option', Html::encode($topic->topicTexts[0]->Title), ['value' => $topic->TopicId]);
             }
         }
     }
     Yii::$app->end();
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTopics()
 {
     return $this->hasMany(Topic::className(), ['ParentId' => 'TopicId'])->orderBy('Order');
 }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTopic()
 {
     return $this->hasOne(Topic::className(), ['TopicId' => 'TopicId']);
 }