From 94dafde0a4e18b15f0343a48c461b93c45485d89 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 12 Jul 2022 10:45:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=B9=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DanmakuQueryController.php | 6 +++- app/Models/VideoDanmakus.php | 14 ++++++++ app/Models/Videos.php | 5 +++ resources/views/danmaku.blade.php | 34 +++++++++++++++++++ resources/views/header.blade.php | 2 +- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 app/Models/VideoDanmakus.php create mode 100644 resources/views/danmaku.blade.php diff --git a/app/Http/Controllers/DanmakuQueryController.php b/app/Http/Controllers/DanmakuQueryController.php index 90a7dd9..2d6c043 100644 --- a/app/Http/Controllers/DanmakuQueryController.php +++ b/app/Http/Controllers/DanmakuQueryController.php @@ -2,12 +2,16 @@ namespace App\Http\Controllers; +use App\Models\Videos; use Illuminate\Routing\Controller as BaseController; class DanmakuQueryController extends BaseController { public function index() { - return view("under_construct"); + $video_list = Videos::query()->withCount("danmakus")->orderByDesc("created_at")->limit(20)->get(); + return view("danmaku", [ + "video_list" => $video_list, + ]); } } diff --git a/app/Models/VideoDanmakus.php b/app/Models/VideoDanmakus.php new file mode 100644 index 0000000..a08225e --- /dev/null +++ b/app/Models/VideoDanmakus.php @@ -0,0 +1,14 @@ +belongsTo(Videos::class, "video_bvid", "bvid"); + } +} diff --git a/app/Models/Videos.php b/app/Models/Videos.php index e9d62fe..1b59d2a 100644 --- a/app/Models/Videos.php +++ b/app/Models/Videos.php @@ -15,4 +15,9 @@ class Videos extends Model { return $this->hasManyThrough(Programs::class, ProgramVideos::class, "video_bvid", "bvid", "id", "program_id"); } + + public function danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(VideoDanmakus::class, "video_bvid", "bvid"); + } } diff --git a/resources/views/danmaku.blade.php b/resources/views/danmaku.blade.php new file mode 100644 index 0000000..29cf7d1 --- /dev/null +++ b/resources/views/danmaku.blade.php @@ -0,0 +1,34 @@ + + + + 录播节目单查询 + + + @include("header") + + + + + + + + + + @foreach($video_list as $video) + + + + + + @endforeach + +
视频标题弹幕条数操作
{{$video->title}}{{$video->danmakus_count}} + @if($video->danmakus_count > 0) + 详情 + @else + 无弹幕 + @endif +
+@include("footer") + + diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 9b0a480..3d19fbb 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -5,6 +5,6 @@ 导航: 节目单查询 节目查询 - 直播弹幕查询 + 直播弹幕查询