|
@@ -286,71 +286,12 @@ class PostRepository
|
|
|
if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count', 'create_bean'])){
|
|
|
$sort = $request['sort'];
|
|
|
}
|
|
|
-
|
|
|
- return $this->post
|
|
|
- ->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
- ->select('post.*')
|
|
|
- ->where($where)
|
|
|
- ->where(function($query) use ($request){
|
|
|
- if(isset($request['keyword'])){
|
|
|
- $query->where('uid', '=', $request['keyword'])
|
|
|
- ->orWhere('username', 'like', "%{$request['keyword']}%")
|
|
|
- ->orWhere('mobile', 'like', "%{$request['keyword']}%");
|
|
|
- }
|
|
|
- })
|
|
|
- ->where(function($query) use ($request){
|
|
|
- if(isset($request['created_at'])){
|
|
|
- $time = explode('_', $request['created_at']);
|
|
|
- $query->whereBetween('post.created_at', $time);
|
|
|
- }
|
|
|
- })
|
|
|
- ->where(function ($query) use ($request){
|
|
|
- if(isset($request['category_ids']) || isset($request['topic_ids'])){
|
|
|
- $ids = [];
|
|
|
- if (isset($request['category_ids'])) {
|
|
|
- $categoryIds = explode('_', $request['category_ids']);
|
|
|
- $ids = $this->categoryTopic->whereIn('category_id', $categoryIds)->pluck('topic_id')->toArray();
|
|
|
- }
|
|
|
- if (isset($request['topic_ids'])) {
|
|
|
- $ids = array_merge($ids, explode('_', $request['topic_ids']));
|
|
|
- }
|
|
|
- foreach ($ids as $key=>$id) {
|
|
|
- if ($key==0) {
|
|
|
- $query = $query->whereRaw('FIND_IN_SET('.$id.',topic_ids)');
|
|
|
- } else {
|
|
|
- $query = $query->orWhereRaw('FIND_IN_SET('.$id.',topic_ids)');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- ->orderBy($sort,'desc')
|
|
|
- ->paginate($perPage);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 回收站列表
|
|
|
- */
|
|
|
- public function waste($request)
|
|
|
- {
|
|
|
- $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
|
|
|
- $where = [];
|
|
|
- if(isset($request['content'])){
|
|
|
- $where[] = ['content', 'like', "%{$request['content']}%"];
|
|
|
- }
|
|
|
- if(isset($request['is_suggest'])){
|
|
|
- $where[] = ['is_suggest', $request['is_suggest']];
|
|
|
- }
|
|
|
- if(isset($request['type'])){
|
|
|
- $where[] = ['type', $request['type']];
|
|
|
- }
|
|
|
-
|
|
|
- $sort = 'post.id';
|
|
|
- if(isset($request['sort']) && in_array($request['sort'], ['praise_count', 'share_count', 'pv', 'comment_count', 'create_bean'])){
|
|
|
- $sort = $request['sort'];
|
|
|
+ $post = $this->post;
|
|
|
+ if(isset($request['waste']) && $request['waste'] == 1){
|
|
|
+ $post = $post->onlyTrashed();
|
|
|
}
|
|
|
|
|
|
- return $this->post
|
|
|
- ->onlyTrashed()
|
|
|
+ return $post
|
|
|
->join('post_data', 'post_data.post_id', '=', 'post.id')
|
|
|
->select('post.*')
|
|
|
->where($where)
|
|
@@ -389,6 +330,7 @@ class PostRepository
|
|
|
->orderBy($sort,'desc')
|
|
|
->paginate($perPage);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 内容详情
|