<?php

namespace App\Models;

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

class Audit extends Model
{
    protected $fillable = ['auditor_id', 'model_type', 'model_id', 'issue_type', 'description', 'status'];

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

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

    public function auditable()
    {
        return $this->morphTo(__FUNCTION__, 'model_type', 'model_id');
    }
}
