Ejemplo n.º 1
0
 /**
  * TAG的关注
  *
  * @return void
  * @author niancode
  **/
 public function storeFollowByTag($tag_id, $user_id)
 {
     $result = [];
     $follow_tag_model = FollowTag::findOne(['tag_id' => $tag_id, 'user_id' => $user_id, 'follow_type' => 'follow']);
     if ($follow_tag_model) {
         $follow_tag_model->delete();
         $result['follow_num'] = $this->_store_stat_with_tag($tag_id, 'follow', false);
     } else {
         $follow_tag_model = new FollowTag();
         $follow_tag_model->tag_id = $tag_id;
         $follow_tag_model->user_id = $user_id;
         $follow_tag_model->follow_type = 'follow';
         $follow_tag_model->follow_active = 0;
         $saved = $follow_tag_model->save(false);
         $result['follow_num'] = $this->_store_stat_with_tag($tag_id, 'follow', true);
     }
     return $result;
 }