<?php

namespace App\Models;

use App\Enums\IssueSentiment;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Swindon\FilamentHashids\Traits\HasHashid;

class IssueManagement extends Model
{
    use HasFactory, HasHashid, SoftDeletes;

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'issue' => IssueSentiment::class,
            'response' => IssueSentiment::class,
        ];
    }

    public function classification(): BelongsTo
    {
        return $this->belongsTo(Classification::class);
    }

    public function departments(): BelongsToMany
    {
        return $this->belongsToMany(Department::class, 'department_issue_management');
    }

    public function location(): BelongsTo
    {
        return $this->belongsTo(Location::class);
    }

    public function mediaMonitoring(): BelongsTo
    {
        return $this->belongsTo(MediaMonitoring::class);
    }

    public function subClassification(): BelongsTo
    {
        return $this->belongsTo(SubClassification::class);
    }

    public function subLocation(): BelongsTo
    {
        return $this->belongsTo(SubLocation::class);
    }
}
