From fb78d7facbb1222d8163816882e26e3e0c1dd508 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 1 Aug 2022 10:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=EF=BC=8C=E6=8B=86=E5=88=86=E8=AF=84=E8=AE=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=8C=E9=BB=98=E8=AE=A4=E8=BF=9B=E5=85=A5=E8=87=B3?= =?UTF-8?q?=E8=8A=82=E7=9B=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Videos.php | 7 ++++++- routes/web.php | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Models/Videos.php b/app/Models/Videos.php index 5e73627..9acfa9d 100644 --- a/app/Models/Videos.php +++ b/app/Models/Videos.php @@ -11,9 +11,14 @@ class Videos extends Model return $this->hasMany(VideoComments::class, "aid", "id"); } + public function program_pivots(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(ProgramVideos::class, "video_bvid", "bvid"); + } + public function programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough { - return $this->hasManyThrough(Programs::class, ProgramVideos::class, "video_bvid", "bvid", "id", "program_id"); + return $this->hasManyThrough(Programs::class, ProgramVideos::class, "video_bvid", "id", "bvid", "program_id")->orderBy("created_at"); } public function danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany diff --git a/routes/web.php b/routes/web.php index a07664c..10899d3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,7 +13,8 @@ use Illuminate\Support\Facades\Route; | */ // 对外列表 -Route::get('/', ["\\App\\Http\\Controllers\\CommentQueryController","index"]); +Route::redirect('/', '/programs'); +Route::get('/comments', ["\\App\\Http\\Controllers\\CommentQueryController","index"]); Route::get('/programs', ["\\App\\Http\\Controllers\\ProgramQueryController","index"]); Route::get('/programs/{program}/video', ["\\App\\Http\\Controllers\\ProgramQueryController","videos"]); Route::get('/danmakus', ["\\App\\Http\\Controllers\\DanmakuQueryController","index"]);