浏览代码

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-manage into develop

durong 5 年之前
父节点
当前提交
9178c37829
共有 2 个文件被更改,包括 10 次插入8 次删除
  1. 0 7
      app/Http/Controllers/Post/PostController.php
  2. 10 1
      app/Repositories/Post/PostRepository.php

+ 0 - 7
app/Http/Controllers/Post/PostController.php

@@ -130,13 +130,6 @@ class PostController extends Controller
      */
     public function commentList(Request $request)
     {
-        $validator = Validator::make($request->all(), [
-            'post_id' => 'required|exists:post,id'
-        ]);
-        if ($validator->fails()) {
-            return $this->response->error($validator->errors()->first(), 500);
-        }
-
         $commentList = $this->postRepository->commentList($request->all());
         $fractal = new Manager();
         $resource = new Collection($commentList, new CommentTransformer());

+ 10 - 1
app/Repositories/Post/PostRepository.php

@@ -365,8 +365,17 @@ class PostRepository
     {
         $perPage = isset($request['per_page']) ? $request['per_page'] : 20;
 
+        $where = [];
+        if(isset($request['post_id'])){
+            $where[] = ['post_id', $request['post_id']];
+        }
+
+        if(isset($request['uid'])){
+            $where[] = ['uid', $request['uid']];
+        }
+
         return $this->postComment
-            ->where('post_id', $request['post_id'])
+            ->where($where)
             ->orderBy('id','desc')
             ->paginate($perPage);
     }