Esempio n. 1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTopicTexts()
 {
     return $this->hasMany(TopicText::className(), ['LCID' => 'LCID']);
 }
Esempio n. 2
0
 /**
  * deleteTopic is a private function
  * Here we written a recursive function
  * to get delete all nested topics
  * @param Integer $id
  */
 private function deleteTopic($id)
 {
     // get child topics
     $topicChildModel = Topic::find()->andFilterWhere(['ParentId' => $id])->all();
     if (!empty($topicChildModel)) {
         foreach ($topicChildModel as $topicChild) {
             $this->deleteTopic($topicChild->TopicId);
         }
     }
     $topicText = TopicText::deleteAll(['TopicId' => $id]);
     $topicModel = $this->loadModel($id)->delete();
 }