弹幕列表

This commit is contained in:
Jerry Yan 2022-07-12 10:45:20 +08:00
parent cd2ccdec87
commit 94dafde0a4
5 changed files with 59 additions and 2 deletions

View File

@ -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,
]);
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class VideoDanmakus extends Model
{
protected $table = "video_danmakus";
public function video(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Videos::class, "video_bvid", "bvid");
}
}

View File

@ -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");
}
}

View File

@ -0,0 +1,34 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目单查询</title>
</head>
<body>
@include("header")
<table border>
<thead>
<tr>
<td>视频标题</td>
<td>弹幕条数</td>
<td>操作</td>
</tr>
</thead>
<tbody>
@foreach($video_list as $video)
<tr>
<td>{{$video->title}}</td>
<td>{{$video->danmakus_count}}</td>
<td>
@if($video->danmakus_count > 0)
<a href="/danmakus/{{$video->bvid}}">详情</a>
@else
无弹幕
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
@include("footer")
</body>
</html>

View File

@ -5,6 +5,6 @@
导航:
<a href="/">节目单查询</a>
<a href="/programs" style="color: gray" title="数据不全,待补充">节目查询</a>
<a href="/danmakus" style="color: white" title="待建设">直播弹幕查询</a>
<a href="/danmakus" style="color: gray" title="数据不全,待补充">直播弹幕查询</a>
</div>
</div>