<?php

namespace App\Models;

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

class GeneralDocument extends Model
{
    use SoftDeletes;

    protected $fillable = ['document_type_id', 'comments', 'uploaded_by'];

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

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

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

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