123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\models\base;
- use Yii;
- /**
- * This is the model class for table "news_topic_relation".
- *
- * @property int $news_id
- * @property int $topic_id
- */
- class NewsTopicRelation extends BaseFrontendClass
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'news_topic_relation';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['news_id', 'topic_id'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'news_id' => 'News ID',
- 'topic_id' => 'Topic ID',
- ];
- }
- /**
- * {@inheritdoc}
- * @return NewsTopicRelationQuery the active query used by this AR class.
- */
- public static function find()
- {
- return new NewsTopicRelationQuery(get_called_class());
- }
- /**
- * {@inheritdoc}
- * @return status
- */
- public function saveNewsTopics($id, $topics)
- {
- $status = true;
- foreach( $topics as $item ){
- $status &= $this->db->createCommand()->insert(NewsTopicRelation::tableName(), [
- 'news_id' => $id,
- 'topic_id' => $item,
- ])->execute();
- }
- return $status;
- }
- }
|