/** * @return \yii\db\ActiveQuery */ public function getSourceTopics() { return $this->hasMany(SourceTopic::className(), ['topic_id' => 'id'])->andFilterWhere(['NOT IN', 'scoopit_source_topic.source_id', $this->excludedNewsItems]); }
public function linkTopic($topicId) { $topic = Topic::findOne($topicId); if (!isset($topic)) { return false; } $out = [true, $topic]; try { $model = new SourceTopic(['topic_id' => $topicId, 'source_id' => $this->id]); if (isset($this->topicPostProcessor)) { $model->postProcessor = $this->topicPostProcessor; } $out[0] = $model->save(); } catch (\Exception $ex) { // echo $ex->getMessage(); $out[0] = false; } return $out; }