39 lines
1.1 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 programs(): \Illuminate\Database\Eloquent\Relations\HasManyThrough
{
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");
}
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);
}
}