diff --git a/app/Http/Controllers/DanmakuQueryController.php b/app/Http/Controllers/DanmakuQueryController.php new file mode 100644 index 0000000..90a7dd9 --- /dev/null +++ b/app/Http/Controllers/DanmakuQueryController.php @@ -0,0 +1,13 @@ +get("keyword", ""); + $programs = Programs::query()->with(["appends", "tags", "video_pivots.video"])->limit(15)->orderByDesc("created_at")->get(); + return view("program", [ + "keyword" => $keyword, + "programs"=>$programs, + ]); + } +} diff --git a/app/Models/ProgramAppends.php b/app/Models/ProgramAppends.php new file mode 100644 index 0000000..45a53c8 --- /dev/null +++ b/app/Models/ProgramAppends.php @@ -0,0 +1,10 @@ +belongsTo(Tags::class, "tag_id", "id"); + } + + public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Programs::class, "program_id", "id"); + } +} diff --git a/app/Models/ProgramVideos.php b/app/Models/ProgramVideos.php new file mode 100644 index 0000000..5c40b4c --- /dev/null +++ b/app/Models/ProgramVideos.php @@ -0,0 +1,27 @@ +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(); + }); + } +} diff --git a/app/Models/Programs.php b/app/Models/Programs.php new file mode 100644 index 0000000..2a8c624 --- /dev/null +++ b/app/Models/Programs.php @@ -0,0 +1,28 @@ +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"); + } +} diff --git a/app/Models/Tags.php b/app/Models/Tags.php new file mode 100644 index 0000000..df43ee6 --- /dev/null +++ b/app/Models/Tags.php @@ -0,0 +1,13 @@ +hasManyThrough(Programs::class, ProgramTags::class, "tag_id", "id", "id", "program_id"); + } +} diff --git a/app/Models/Videos.php b/app/Models/Videos.php index a397480..e9d62fe 100644 --- a/app/Models/Videos.php +++ b/app/Models/Videos.php @@ -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"); + } } diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 759a334..9b0a480 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -1,4 +1,10 @@
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 9550c27..255f552 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -24,8 +24,8 @@节目名称 | +节目标签 | +点播及追加 | +视频地址及位置 | +
{{$program->name}} | +
+ @foreach($program->tags as $tag)
+ {{$tag->name}}
+ @endforeach
+ |
+
+ @foreach($program->appends as $append)
+ @if($append->is_original)
+
+ @if($append->from_mid)
+ {{$append->from}}
+ @else
+ {{$append->from}}
+ @endif
+ 老板点播
+ {{$append->price}}分
+ @if($append->append)
+ ({{$append->append}})
+ @endif
+
+ @else
+
+ @if($append->from_mid)
+ {{$append->from}}
+ @else
+ {{$append->from}}
+ @endif
+ 老板追加:{{$append->name}}
+ {{$append->price}}分
+ @if($append->append)
+ ({{$append->append}})
+ @endif
+
+ @endif
+ @endforeach
+ |
+ + @foreach($program->video_pivots as $video_pivot) + + 节目开始位置 + + @endforeach + | +