You've already forked lubo_comment_query
弹幕列表
This commit is contained in:
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
14
app/Models/VideoDanmakus.php
Normal file
14
app/Models/VideoDanmakus.php
Normal 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");
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user