44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Videos extends Model
|
|
{
|
|
public function comments(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
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", "id", "bvid", "program_id")->orderBy("created_at");
|
|
}
|
|
|
|
public function danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->hasMany(VideoDanmakus::class, "video_bvid", "bvid");
|
|
}
|
|
|
|
public function bilibili_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->danmakus()->where("platform_id", "=", 1);
|
|
}
|
|
|
|
public function ixigua_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->danmakus()->where("platform_id", "=", 2);
|
|
}
|
|
|
|
public function douyin_danmakus(): \Illuminate\Database\Eloquent\Relations\HasMany
|
|
{
|
|
return $this->danmakus()->where("platform_id", "=", 3);
|
|
}
|
|
}
|