<?php

namespace App\Models;

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

class Series extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'category_id',
        'thumbnail_image',
        'description',
        'total_views',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'status'      => 'integer',
            'total_views' => 'integer',
        ];
    }

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function seasons()
    {
        return $this->hasMany(Season::class)->orderBy('season_number');
    }

    public function episodes()
    {
        return $this->hasMany(Episode::class);
    }
}
