You've already forked lubo_comment_query
							
							
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| 
 | |
| class Videos extends Model
 | |
| {
 | |
|     protected $dateFormat = 'U';
 | |
|     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);
 | |
|     }
 | |
| 
 | |
|     public function parts(): \Illuminate\Database\Eloquent\Relations\HasMany
 | |
|     {
 | |
|         return $this->hasMany(VideoParts::class, "bvid", "bvid");
 | |
|     }
 | |
| }
 |