Browse Source

:construction: 增加语言和channel 的查询

visuddhinanda@gmail.com 3 years ago
parent
commit
4cdd64e3ff
1 changed files with 16 additions and 0 deletions
  1. 16 0
      app/Http/Controllers/ProgressChapterController.php

+ 16 - 0
app/Http/Controllers/ProgressChapterController.php

@@ -125,10 +125,26 @@ class ProgressChapterController extends Controller
                     $all_count = count($chapters);
                 break;
             case 'lang':
+                $chapters = ProgressChapter::select('lang')
+                                            ->selectRaw('count(*) as count')
+                                            ->where("progress",">",$minProgress)
+                                            ->groupBy('lang')
+                                            ->get();
+                $all_count = count($chapters);
                 break;
             case 'channel-type':
                 break;
             case 'channel':
+                $chapters = ProgressChapter::select('channel_id')
+                                            ->selectRaw('count(*) as count')
+                                            ->with(['channel' => function($query) {  //city对应上面province模型中定义的city方法名  闭包内是子查询
+                                                return $query->select('*');
+                                            }])
+                                            ->where("progress",">",$minProgress)
+                                            ->groupBy('channel_id')
+                                            ->orderBy('count','desc')
+                                            ->get();
+                $all_count = count($chapters);
                 break;
             case 'chapter':
                 $tm = (new TagMap)->getTable();