diff --git a/app/Http/Controllers/DanmakuQueryController.php b/app/Http/Controllers/DanmakuQueryController.php index 206e9f7..dab6964 100644 --- a/app/Http/Controllers/DanmakuQueryController.php +++ b/app/Http/Controllers/DanmakuQueryController.php @@ -11,7 +11,10 @@ class DanmakuQueryController extends BaseController { public function index() { - $video_list = Videos::query()->withCount("danmakus")->orderByDesc("created_at")->paginate(10); + $video_list = Videos::query() + ->withCount("danmakus", "bilibili_danmakus", "ixigua_danmakus", "douyin_danmakus") + ->orderByDesc("created_at") + ->paginate(10); return view("danmaku.index", [ "video_list" => $video_list, ]); diff --git a/app/Models/Videos.php b/app/Models/Videos.php index 1b59d2a..5e73627 100644 --- a/app/Models/Videos.php +++ b/app/Models/Videos.php @@ -20,4 +20,19 @@ class Videos extends Model { return $this->hasMany(VideoDanmakus::class, "video_bvid", "bvid"); } + + public function bilibili_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->danmakus()->where("platform_id", "=", 1); + } + + public function ixigua_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->danmakus()->where("platform_id", "=", 2); + } + + public function douyin_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->danmakus()->where("platform_id", "=", 3); + } } diff --git a/resources/views/danmaku/index.blade.php b/resources/views/danmaku/index.blade.php index 8eaf75f..4690f9e 100644 --- a/resources/views/danmaku/index.blade.php +++ b/resources/views/danmaku/index.blade.php @@ -21,6 +21,15 @@ @if($video->danmakus_count > 0) {{$video->title}} + @if($video->bilibili_danmakus_count > 0) + B站 + @endif + @if($video->ixigua_danmakus_count > 0) + 西瓜视频 + @endif + @if($video->douyin_danmakus_count > 0) + 抖音 + @endif @else {{$video->title}} @endif diff --git a/resources/views/danmaku/search_index.blade.php b/resources/views/danmaku/search_index.blade.php index 48729b2..bf62dd4 100644 --- a/resources/views/danmaku/search_index.blade.php +++ b/resources/views/danmaku/search_index.blade.php @@ -37,6 +37,10 @@ 西瓜视频 {{$danmaku->from}} @break + @case(3) + 抖音 + {{$danmaku->from}} + @break @default {{$danmaku->from}} @break