public function query($index) { $uid = $this->userid ? $this->userid : 0; //1click,2collect,3follow,4reply,5share,6thank if ($index) { if ($index == 1) { $models = TalksClickModel::where('uid', $uid)->get(); } elseif ($index == 2) { $models = TalksCollectModel::where('uid', $uid)->get(); } elseif ($index == 3) { $models = TalksFollowModel::where('uid', $uid)->get(); } elseif ($index == 4) { $models = TalksReportModel::where('uid', $uid)->get(); } elseif ($index == 5) { $models = TalksShareModel::where('uid', $uid)->get(); } elseif ($index == 6) { $models = TalksThankModel::where('uid', $uid)->get(); } $ids = array(); if (isset($models) && count($models)) { foreach ($models as $model) { $ids[] = $model->talkid; } } $datas = TalksModel::whereIn('id', $ids)->orderBy('sort', 'desc')->orderBy('id', 'desc')->paginate($this->limit); } else { $datas = TalksModel::where('uid', $uid)->orderBy('sort', 'desc')->orderBy('id', 'desc')->paginate($this->limit); } $datas->limit = $this->limit; return $datas; }
/** * 关注的话题 */ public function follow() { $this->islogin(); $follows = TalksFollowModel::where('uid', $this->userid)->get(); if (count($follows)) { foreach ($follows as $follow) { $followIds[] = $follow->talkid; } } if (isset($followIds) && $followIds) { $datas = TalksModel::where('del', 0)->whereId('id', $followIds)->orderBy('sort', 'desc')->orderBy('id', 'desc')->paginate($this->limit); $datas->limit = $this->limit; } $result = ['datas' => isset($datas) ? $datas : [], 'curr' => 'follow']; return view('home.talk.index', $result); }
/** * 关注话题 */ public function follow() { $datas = TalksFollowModel::where('talkid', $this->id)->get(); return count($datas) ? $datas : 0; }