<?php

namespace App\Models;

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

class MedicalRecordAttachment extends Model
{
    protected $fillable = [
        'medical_record_id',
        'path',
        'original_name',
        'mime',
        'size',
    ];

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

    public function isImage(): bool
    {
        return $this->mime !== null && str_starts_with($this->mime, 'image/');
    }

    public function isPdf(): bool
    {
        return $this->mime === 'application/pdf';
    }

    public function isVideo(): bool
    {
        return $this->mime !== null && str_starts_with($this->mime, 'video/');
    }
}
