<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Show extends Model
{
    protected $fillable = [
        'tmdb_id', 'imdb_id', 'title', 'slug', 'overview', 'poster_path',
        'backdrop_path', 'top_cast', 'first_air_date', 'vote_average',
        'content_rating', 'trailer_key', 'seo_title', 'meta_description',
        'keywords', 'is_featured', 'is_active',
    ];

    protected function casts(): array
    {
        return [
            'first_air_date' => 'date',
            'is_featured' => 'boolean',
            'is_active' => 'boolean',
            'top_cast' => 'array',
        ];
    }

    public function genres()
    {
        return $this->belongsToMany(Genre::class);
    }

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

    public function getRouteKeyName()
    {
        return 'slug';
    }
}
