<?php

namespace App\Models\Document;

use App\Casts\FileSize;
use App\Models\User\User;
use Illuminate\Database\Eloquent\Model;

class Document extends Model {
    protected $table = 'documents';
    protected $fillable = [
        'user_id',
        'display_name',
        'file_name',
        'file_type',
        'file_size',
        'type_id',
    ];

    protected $casts = [
        'file_size' => FileSize::class,
    ];


    public function user() {
        return $this->belongsTo(User::class);
    }

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

    public function owner() {
        return $this->morphTo();
    }
}
