wzq пре 5 година
родитељ
комит
a3c8e111a1

+ 8 - 1
app/Repositories/FeedRepositories.php

@@ -205,7 +205,14 @@ class FeedRepositories
         ];
     }
     public function getPostComment($post_id){
-       return $this->postComment->where(['post_id'=>$post_id,'parent_id'=>0,'is_delete'=>0  ])->select('id','uid','username','content')->orderBy('id','desc')->take(2)->get();
+       $comments = $this->postComment->where(['post_id'=>$post_id,'parent_id'=>0])->select('id','uid','username','content','is_delete')->orderBy('is_delete', 'asc')->orderBy('id', 'desc')->take(2)->get();
+       foreach($comments as &$comment){
+           if($comment->is_delete){
+                $comment->content = '该评论已被删除';
+           }
+           unset($comment->is_delete);
+       }
+       return $comments;
     }
 
     /**

+ 1 - 1
app/Transformers/Post/SuggestTransformer.php

@@ -32,7 +32,7 @@ class SuggestTransformer extends TransformerAbstract
             $imgs[] = $img['img'];
         }
         $comment = [];
-        $comments = PostComment::where('post_id', $post['id'])->where('parent_id', 0)->orderBy('id', 'desc')->limit(2)->get();
+        $comments = PostComment::where('post_id', $post['id'])->where('parent_id', 0)->orderBy('is_delete', 'asc')->orderBy('id', 'desc')->limit(2)->get();
         foreach($comments as $item){
             $comment[] = [
                 'id' => $item->id,