<?php

namespace App\Models;

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

/**
 * App\Models\EpisodesList.
 *
 * @property int                             $id
 * @property int|null                        $episodes_id 短剧ID
 * @property int                             $sort        第几集
 * @property string                          $url         视频链接
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 *
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList newQuery()
 * @method static \Illuminate\Database\Query\Builder|EpisodesList onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList query()
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereEpisodesId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereSort($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereUrl($value)
 * @method static \Illuminate\Database\Query\Builder|EpisodesList withTrashed()
 * @method static \Illuminate\Database\Query\Builder|EpisodesList withoutTrashed()
 *
 * @mixin \Eloquent
 *
 * @property \App\Models\Episode|null $episode
 * @property int                      $is_free      是否免费
 * @property string|null              $origin_price 原价
 * @property int                      $sale_price   价格
 *
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereIsFree($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereOriginPrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|EpisodesList whereSalePrice($value)
 */
class EpisodesList extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'episodes_lists';

    protected $hidden = [
        'updated_at', 'deleted_at',
    ];

    protected $casts = [
        'sale_price'   => 'integer',
        'origin_price' => 'integer',
        'url'          => HttpToHttps::class,
    ];

    public function episode()
    {
        return $this->belongsTo(Episode::class, 'episodes_id', 'id')->withTrashed();
    }
}
