Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 /**
  * 收藏话题
  */
 public function tocollect($id)
 {
     $msg = '不能收藏自己的话题';
     TalksCollectModel::create($this->tolimit($id, $msg));
     return redirect('/talk/follow');
 }
Ejemplo n.º 3
0
 /**
  * 收集话题
  */
 public function collect()
 {
     $datas = TalksCollectModel::where('talkid', $this->id)->get();
     return count($datas) ? $datas : 0;
 }