补充亿点内容,顺便立Flag

This commit is contained in:
Jerry Yan 2022-07-10 16:44:30 +08:00
parent 48e2217961
commit 7ed59ddfd2
13 changed files with 235 additions and 3 deletions

View File

@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
class DanmakuQueryController extends BaseController
{
public function index()
{
return view("under_construct");
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use App\Models\Programs;
use App\Models\Tags;
use Illuminate\Routing\Controller as BaseController;
class ProgramQueryController extends BaseController
{
public function index() {
$keyword = request()->get("keyword", "");
$programs = Programs::query()->with(["appends", "tags", "video_pivots.video"])->limit(15)->orderByDesc("created_at")->get();
return view("program", [
"keyword" => $keyword,
"programs"=>$programs,
]);
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProgramAppends extends Model
{
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProgramTags extends Model
{
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Tags::class, "tag_id", "id");
}
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Programs::class, "program_id", "id");
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class ProgramVideos extends Model
{
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Programs::class, "program_id", "id");
}
public function video(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Videos::class, "video_bvid", "bvid");
}
public function startSec(): Attribute
{
return Attribute::get(function ($_, $attributes) {
return Carbon::createFromFormat("H:i:s", $attributes['start_time'])->secondsSinceMidnight();
});
}
}

28
app/Models/Programs.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Programs extends Model
{
public function appends(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ProgramAppends::class, "program_id", "id")->orderByDesc("is_original");
}
public function tags(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{
return $this->hasManyThrough(Tags::class, ProgramTags::class, "program_id", "id", "id", "tag_id");
}
public function video_pivots(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ProgramVideos::class, "program_id", "id");
}
public function videos(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{
return $this->hasManyThrough(Videos::class, ProgramVideos::class, "program_id", "bvid", "id", "video_bvid");
}
}

13
app/Models/Tags.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Tags extends Model
{
public function programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{
return $this->hasManyThrough(Programs::class, ProgramTags::class, "tag_id", "id", "id", "program_id");
}
}

View File

@ -10,4 +10,9 @@ class Videos extends Model
{
return $this->hasMany(VideoComments::class, "aid", "id");
}
public function programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{
return $this->hasManyThrough(Programs::class, ProgramVideos::class, "video_bvid", "bvid", "id", "program_id");
}
}

View File

@ -1,4 +1,10 @@
<div>
<h1>非专业人士,制作不易,请大家多多谅解</h1>
<p>有任何意见或建议可以直接联系我</p>
<div>有任何意见或建议可以直接联系我</div>
<div>
导航:
<a href="/">节目单查询</a>
<a href="/programs" style="color: gray" title="数据不全,待补充">节目查询</a>
<a href="/danmakus" style="color: white" title="待建设">直播弹幕查询</a>
</div>
</div>

View File

@ -24,8 +24,8 @@
<tr>
<td>{{$comment->video->title}}</td>
<td style="white-space: pre-wrap;">{{$comment->content}}</td>
<td><a href="https://space.bilibili.com/{{$comment->mid}}">B站主页</a></td>
<td><a href="https://www.bilibili.com/video/{{$comment->video->bvid}}">{{$comment->video->bvid}}</a></td>
<td><a target="_blank" href="https://space.bilibili.com/{{$comment->mid}}">B站主页</a></td>
<td><a target="_blank" href="https://www.bilibili.com/video/{{$comment->video->bvid}}">{{$comment->video->bvid}}</a></td>
</tr>
@endforeach
</tbody>

View File

@ -0,0 +1,80 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目查询</title>
</head>
<body>
@include("header")
<h3>搜索功能待开放,数据待补充完整</h3>
<!--<form action="">
<label for="keyword">查找节目关键词,空格隔开查找多个关键词</label>
<input type="text" name="keyword" id="keyword" value="{{$keyword}}">
<input type="submit">
</form>-->
<table border>
<thead>
<tr>
<td>节目名称</td>
<td>节目标签</td>
<td>点播及追加</td>
<td>视频地址及位置</td>
</tr>
</thead>
<tbody>
@foreach($programs as $program)
<tr>
<td>{{$program->name}}</td>
<td>
@foreach($program->tags as $tag)
<div title="{{$tag->comment}}">{{$tag->name}}</div>
@endforeach
</td>
<td>
@foreach($program->appends as $append)
@if($append->is_original)
<div>
@if($append->from_mid)
<a target="_blank" href="https://space.bilibili.com/{{$append->from_mid}}">{{$append->from}}</a>
@else
{{$append->from}}
@endif
老板点播
<span title="一分10块">{{$append->price}}</span>
@if($append->append)
<span>{{$append->append}}</span>
@endif
</div>
@else
<div>
@if($append->from_mid)
<a target="_blank" href="https://space.bilibili.com/{{$append->from_mid}}">{{$append->from}}</a>
@else
{{$append->from}}
@endif
老板追加:{{$append->name}}
<span title="一分10块">{{$append->price}}</span>
@if($append->append)
<span>{{$append->append}}</span>
@endif
</div>
@endif
@endforeach
</td>
<td>
@foreach($program->video_pivots as $video_pivot)
<a
target="_blank"
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
>
节目开始位置
</a>
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
@include("footer")
</body>
</html>

View File

@ -0,0 +1,11 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>正在建设中</title>
</head>
<body>
@include("header")
<h1>正在建设中</h1>
@include("footer")
</body>
</html>

View File

@ -14,3 +14,5 @@ use Illuminate\Support\Facades\Route;
*/
Route::get('/', "\\App\\Http\\Controllers\\CommentQueryController@index");
Route::get('/programs', "\\App\\Http\\Controllers\\ProgramQueryController@index");
Route::get('/danmakus', "\\App\\Http\\Controllers\\DanmakuQueryController@index");