<?php

namespace App\Models;

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

class Content extends Model
{
    use HasFactory;

    protected $fillable = [
        'category_id',
        'title',
        'slug',
        'description',
        'content_type',
        'thumbnail',
        'banner',
        'tags',
        'meta_keywords',
        'meta_description',
        'is_premium',
        'price',
        'duration',
        'file_size',
        'views_count',
        'likes_count',
        'downloads_count',
        'points_reward',
        'sort_order',
        'status',
        'published_at',
    ];

    protected $casts = [
        'tags' => 'array',
        'is_premium' => 'boolean',
        'published_at' => 'datetime',
    ];

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

    public function files()
    {
        return $this->hasMany(ContentFile::class);
    }

    public function playlistItems()
    {
        return $this->hasMany(PlaylistItem::class);
    }
}
