<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Episode
 *
 * @property int $id
 * @property int $category_id 分类
 * @property string $name 名称
 * @property string $cover_img 名称
 * @property int $status 状态 0-更新中 1-已完结
 * @property int $is_opend 上架状态 0-下架 1-上架
 * @property int $sort 排序
 * @property int $is_vip_watch 是否限定VIP观看
 * @property int $free_episodes 免费集数
 * @property int $paid_episodes 付费集数
 * @property string $episodes_price 单集价格设置
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property-read \App\Models\EpisodesCategory|null $category
 * @property-read \App\Models\EpisodesList|null $lists
 * @method static \Illuminate\Database\Eloquent\Builder|Episode newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Episode newQuery()
 * @method static \Illuminate\Database\Query\Builder|Episode onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|Episode query()
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereCategoryId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereCoverImg($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereEpisodesPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereFreeEpisodes($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereIsOpend($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereIsVipWatch($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode wherePaidEpisodes($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Episode whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|Episode withTrashed()
 * @method static \Illuminate\Database\Query\Builder|Episode withoutTrashed()
 * @mixin \Eloquent
 * @property-read \App\Models\UserEpisodesRecord|null $userEpisodesRecords
 */
class Episode extends Model
{
	use HasDateTimeFormatter,SoftDeletes;


    public function category()
    {
        return $this->belongsTo(EpisodesCategory::class,'category_id','id');
	}

    public function lists()
    {
        return $this->belongsTo(EpisodesList::class,'id','episodes_id');
    }

    public function userEpisodesRecords()
    {
        return $this->hasMany(UserEpisodesRecord::class,'episodes_id','id');
    }
}
