Browse Source

discussion_tree 只输出有children 的

visuddhinanda 2 years ago
parent
commit
63f3b323d6
1 changed files with 15 additions and 12 deletions
  1. 15 12
      app/Http/Controllers/DiscussionController.php

+ 15 - 12
app/Http/Controllers/DiscussionController.php

@@ -103,18 +103,21 @@ class DiscussionController extends Controller
                                 ->whereNull('parent')
                                 ->select('title','children_count','editor_uid')
                                 ->orderBy('created_at','desc')->get();
-                $output[] = [
-                    'sentence' => [
-                        'book' => $sentInfo->book_id,
-                        'paragraph' => $sentInfo->paragraph,
-                        'word_start' => $sentInfo->word_start,
-                        'word_end' => $sentInfo->word_end,
-                        'channel_id' => $sentInfo->channel_uid,
-                        'content' => $sentInfo->content,
-                        'pr_count' => count($sentPr),
-                    ],
-                    'pr' => $sentPr,
-                ];
+                if(count($sentPr)>0){
+                    $output[] = [
+                        'sentence' => [
+                            'book' => $sentInfo->book_id,
+                            'paragraph' => $sentInfo->paragraph,
+                            'word_start' => $sentInfo->word_start,
+                            'word_end' => $sentInfo->word_end,
+                            'channel_id' => $sentInfo->channel_uid,
+                            'content' => $sentInfo->content,
+                            'pr_count' => count($sentPr),
+                        ],
+                        'pr' => $sentPr,
+                    ];
+                }
+
             }
 
         }