<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class VideoCollect extends BaseModel
{
    use HasFactory;
    protected $table = 'video_collect';

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function video()
    {
        return $this->hasOne(Video::class,'id', 'video_id');
    }

    public function videoUser()
    {
        return $this->hasOne(User::class, 'id', 'video_user_id');
    }

    public static function isCollect($video_id,$user_id){
        $is_collect = false;
        $collect_info = self::where('video_id',$video_id)->where('user_id',$user_id)->exists();
        if($collect_info){
            $is_collect = true;
        }
        return $is_collect;
    }
}
