|
@@ -318,14 +318,16 @@ class PostRepositories
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
$perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
|
|
|
$where = [];
|
|
$where = [];
|
|
|
|
+ $id = 0;
|
|
if(isset($request['id'])){
|
|
if(isset($request['id'])){
|
|
- $where[] = ['post.id', '<>', $request['id']];
|
|
|
|
|
|
+ $id = $request['id'];
|
|
}
|
|
}
|
|
$where[] = ['type', 'video'];
|
|
$where[] = ['type', 'video'];
|
|
return $this->post
|
|
return $this->post
|
|
->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
- ->select('post.*')
|
|
|
|
|
|
+ ->select('post.*', DB::raw("IF (post.id = {$id},1,0) as sort"))
|
|
->where($where)
|
|
->where($where)
|
|
|
|
+ ->orderBy('sort', 'desc')
|
|
->orderBy('weight','desc')
|
|
->orderBy('weight','desc')
|
|
->paginate($perPage);
|
|
->paginate($perPage);
|
|
}
|
|
}
|
|
@@ -536,5 +538,37 @@ class PostRepositories
|
|
->find($id);
|
|
->find($id);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取话题
|
|
|
|
+ */
|
|
|
|
+ public function getTopic($ids)
|
|
|
|
+ {
|
|
|
|
+ $topics = $this->topic
|
|
|
|
+ ->whereIn('id', explode(',',$ids))
|
|
|
|
+ ->get();
|
|
|
|
+ $data = [];
|
|
|
|
+ foreach($topics as $topic){
|
|
|
|
+ $data[] = [
|
|
|
|
+ 'id' => $topic->id,
|
|
|
|
+ 'name' => $topic->name,
|
|
|
|
+ 'img' => $topic->img,
|
|
|
|
+ 'follow_count' => $topic->follow->count() + 9876,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取内容视频组
|
|
|
|
+ */
|
|
|
|
+ public function getPostVideo($ids)
|
|
|
|
+ {
|
|
|
|
+ return $this->post
|
|
|
|
+ ->select('id', 'img', 'uid', 'username', 'avatar')
|
|
|
|
+ ->whereIn('id', explode(',',$ids))
|
|
|
|
+ ->where('type', 'video')
|
|
|
|
+ ->get();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|