<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Department extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'slug',
        'email',
        'auto_assign_to',
        'sla_policy_id',
        'sort_order',
    ];

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

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

    public function autoAssignee(): BelongsTo
    {
        return $this->belongsTo(User::class, 'auto_assign_to');
    }
}
