<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Swindon\FilamentHashids\Traits\HasHashid;

class MediaMonitoring extends Model implements HasMedia
{
    use HasFactory, HasHashid, InteractsWithMedia, SoftDeletes;

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'release_date' => 'date',
        ];
    }

    public function issueManagement(): HasOne
    {
        return $this->hasOne(IssueManagement::class);
    }

    public function mediaMonitoringThemes(): HasMany
    {
        return $this->hasMany(MediaMonitoringTheme::class);
    }

    public function themes(): BelongsToMany
    {
        return $this->belongsToMany(Theme::class, 'media_monitoring_theme');
    }
}
